-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ iNZightTS.Rproj | |
*.Rcheck | ||
*.tar.gz | ||
CRAN-SUBMISSION | ||
inst/doc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
#' @importFrom rlang ':=' | ||
#' | ||
#' @name iNZightTS-package | ||
NULL | ||
"_PACKAGE" | ||
|
||
|
||
utils::globalVariables(c( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#' @export | ||
fit_model <- function(data, x, method = c("arima", "ets"), ...) { | ||
method <- match.arg(method) | ||
fit <- switch(method, | ||
"arima" = fabletools::model(data, fit = fable::ARIMA(rlang::enquo(x), ...)), | ||
"ets" = fabletools::model(data, fit = fable::ETS(rlang::enquo(x), ...)) | ||
) | ||
attr(fit, "method") <- method | ||
attr(fit, "checked") <- FALSE | ||
class(fit) <- c("inzts_fit", class(fit)) | ||
fit | ||
} | ||
|
||
#' @export | ||
print.inzts_fit <- function(x, ...) { | ||
cat("Model: ", attr(x, "method"), "\n") | ||
print.default(x, ...) | ||
|
||
if (!attr(x, "checked")) { | ||
cat("Warning: model has not been checked for assumptions.\n") | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.html | ||
*.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: "model-checking" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{model-checking} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(iNZightTS) | ||
``` | ||
|
||
```{r tsObject} | ||
visitors_ts <- inzightts(visitorsQ) | ||
plot(visitors_ts, "Australia") | ||
``` | ||
|
||
```{r model-checking, eval=FALSE} | ||
visitors_fit <- fit_model(visitors_ts, ~Australia, method = "arima") | ||
visitors_fit | ||
plot(visitors_fit) | ||
``` | ||
|
||
Without any model checking, outputs show warnings. | ||
|
||
To check the model, we can use the `check_model` function. This will launch an interactive process where we can check the model assumptions are satisfied. |