plot_mvgam_forecasts | R Documentation |
Plot posterior forecast predictions from mvgam models
plot_mvgam_fc(
object,
series = 1,
newdata,
data_test,
realisations = FALSE,
n_realisations = 15,
hide_xlabels = FALSE,
xlab,
ylab,
ylim,
n_cores = 1,
return_forecasts = FALSE,
return_score = FALSE,
...
)
## S3 method for class 'mvgam_forecast'
plot(
x,
series = 1,
realisations = FALSE,
n_realisations = 15,
xlab,
ylab,
ylim,
...
)
object |
|
series |
|
newdata |
Optional |
data_test |
Deprecated. Still works in place of |
realisations |
|
n_realisations |
|
hide_xlabels |
|
xlab |
label for x axis. |
ylab |
label for y axis. |
ylim |
Optional |
n_cores |
|
return_forecasts |
|
return_score |
|
... |
further |
x |
Object of class |
plot_mvgam_fc
generates posterior predictions from an object of class mvgam
, calculates posterior
empirical quantiles and plots them against the observed data. If realisations = FALSE
, the returned plot shows
90, 60, 40 and 20 percent posterior quantiles (as ribbons of increasingly darker shades or red)
as well as the posterior median (as a dark red line). If realisations = FALSE
, a set of n_realisations
posterior
draws are shown. This function produces an older style base R
plot, as opposed to plot.mvgam_forecast
plot.mvgam_forecast
takes an object of class mvgam_forecast
, in which forecasts have already
been computed, and plots the resulting forecast distribution as a ggplot
object. This function is therefore more
versatile and is recommended over the older and clunkier plot_mvgam_fc
version
If realisations = FALSE
, these posterior quantiles are plotted along
with the true observed data that was used to train the model. Otherwise, a spaghetti plot is returned
to show possible forecast paths.
A base R
graphics plot (for plot_mvgam_fc
) or a ggplot
object (for plot.mvgam_forecast
) and an optional list
containing the forecast distribution
and the out of sample probabilistic forecast score
simdat <- sim_mvgam(n_series = 3, trend_model = AR())
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)
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)
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
# Forecasts as expectations
fc <- forecast(mod, newdata = simdat$data_test, type = 'expected')
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
# Dynamic trend extrapolations
fc <- forecast(mod, newdata = simdat$data_test, type = 'trend')
plot(fc, series = 1)
plot(fc, series = 2)
plot(fc, series = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.