View source: R/forecast.mvgam.R
| forecast.mvgam | R Documentation |
mvgam objectExtract or compute hindcasts and forecasts for a fitted
mvgam object
## S3 method for class 'mvgam'
forecast(object, newdata, data_test, n_cores = 1, type = "response", ...)
object |
|
newdata |
Optional |
data_test |
Deprecated. Still works in place of |
n_cores |
Deprecated. Parallel processing is no longer supported |
type |
When this has the value |
... |
Ignored |
Posterior predictions are drawn from the fitted mvgam and
used to simulate a forecast distribution
An object of class mvgam_forecast containing hindcast and
forecast distributions. See mvgam_forecast-class for
details.
hindcast.mvgam(), plot.mvgam_forecast(),
summary.mvgam_forecast(), score.mvgam_forecast()
ensemble.mvgam_forecast()
## Not run:
# Simulate data with 3 series and AR trend model
simdat <- sim_mvgam(n_series = 3, trend_model = AR())
# Fit mvgam model
mod <- mvgam(
y ~ s(season, bs = 'cc', k = 6),
trend_model = AR(),
noncentred = TRUE,
data = simdat$data_train,
chains = 2,
silent = 2
)
# Hindcasts on response scale
hc <- hindcast(mod)
str(hc)
# Use summary() to extract hindcasts / forecasts for custom plotting
head(summary(hc), 12)
# Or just use the plot() function for quick plots
plot(hc, series = 1)
plot(hc, series = 2)
plot(hc, series = 3)
# Forecasts on response scale
fc <- forecast(
mod,
newdata = simdat$data_test
)
str(fc)
head(summary(fc), 12)
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
# Forecasts as expectations
fc <- forecast(
mod,
newdata = simdat$data_test,
type = 'expected'
)
head(summary(fc), 12)
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
# Dynamic trend extrapolations
fc <- forecast(
mod,
newdata = simdat$data_test,
type = 'trend'
)
head(summary(fc), 12)
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.