View source: R/forecast_tools.R
test_forecast | R Documentation |
Visualize the fitted values of the training set and the forecast values of the testing set against the actual values of the series
test_forecast(actual, forecast.obj, train = NULL, test, Ygrid = FALSE,
Xgrid = FALSE, hover = TRUE)
actual |
The full time series object (supports "ts", "zoo" and "xts" formats) |
forecast.obj |
The forecast output of the training set with horizon align to the length of the testing (support forecasted objects from the “forecast” package) |
train |
Training partition, a subset of the first n observation in the series (not requiredthed) |
test |
The testing (hold-out) partition |
Ygrid |
Logic,show the Y axis grid if set to TRUE |
Xgrid |
Logic,show the X axis grid if set to TRUE |
hover |
If TRUE add tooltip with information about the model accuracy |
## Not run:
library(forecast)
data(USgas)
# Set the horizon of the forecast
h <- 12
# split to training/testing partition
split_ts <- ts_split(USgas, sample.out = h)
train <- split_ts$train
test <- split_ts$test
# Create forecast object
fc <- forecast(auto.arima(train, lambda = BoxCox.lambda(train)), h = h)
# Plot the fitted and forecasted vs the actual values
test_forecast(actual = USgas, forecast.obj = fc, test = test)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.