forecast.bmgarch: Forecast method for bmgarch objects.

View source: R/forecasting_gq.R

forecast.bmgarchR Documentation

Forecast method for bmgarch objects.

Description

Estimates (weighted) forecasted means, variances, and correlations from a fitted bmgarch model.

Usage

## S3 method for class 'bmgarch'
forecast(
  object,
  ahead = 1,
  xC = NULL,
  newdata = NULL,
  CrI = c(0.025, 0.975),
  seed = NA,
  digits = 2,
  weights = NULL,
  L = NA,
  method = "stacking",
  inc_samples = FALSE,
  ...
)

Arguments

object

bmgarch object.

ahead

Integer (Default: 1). Periods to be forecasted ahead.

xC

Numeric vector or matrix. Covariates(s) for the constant variance terms in C, or c. Used in a log-linear model on the constant variance terms. If vector, then it acts as a covariate for all constant variance terms. If matrix, must have columns equal to number of time series, and each column acts as a covariate for the respective time series (e.g., column 1 predicts constant variance for time series 1).

newdata

Future datapoints for LFO-CV computation

CrI

Numeric vector (Default: c(.025, .975)). Lower and upper bound of predictive credible interval.

seed

Integer (Optional). Specify seed for sampling.

digits

Integer (Default: 2, optional). Number of digits to round to when printing.

weights

Takes weights from model_weight function. Defaults to 1 – this parameter is not typically set by user.

L

Minimal length of time series before engaging in lfocv

method

Ensemble methods, 'stacking' (default) or 'pseudobma'

inc_samples

Logical (Default: FALSE). Whether to return the MCMC samples for the fitted values.

...

Not used

Value

forecast.bmgarch object. List containing forecast, backcast, and metadata. See fitted.bmgarch for information on backcast. forecast is a list of four components:

mean

[N, 7, TS] array of mean forecasts, where N is the timeseries length, and TS is the number of time series. E.g., fc$forecast$mean[3,,"tsA"] is the 3-ahead mean forecast for time series "tsA".

var

[N, 7, TS] array of variance forecasts, where N is the timeseries length, and TS is the number of time series. E.g., fc$forecast$var[3,,"tsA"] is the 3-ahead variance forecast for time series "tsA".

cor

[N, 7, TS(TS - 1)/2] array of correlation forecasts, where N is the timeseries length, and TS(TS - 1)/2 is the number of correlations. E.g., fc$forecast$cor[3,, "tsB_tsA"] is the 3-ahead forecast for the correlation between "tsB" and "tsA". Lower triangular correlations are saved.

meta

Meta-data specific to the forecast. I.e., TS_length (number ahead) and xC.

samples

List

. If inc_samples is TRUE, then a list of arrays of MCMC samples for means, vars, and cors. Each array is [Iteration, Period, ..., ...].

Examples

## Not run: 
data(panas)
# Fit DCC(2,2) with constant mean structure.
fit <- bmgarch(panas, parameterization = "DCC", P = 2, Q = 2, meanstructure = "constant")

# Forecast 8 ahead
fit.fc <- forecast(fit, ahead = 8)

# Print forecasts
fit.fc
print(fit.fc)

# Plot variance forecasts
plot(fit.fc, type = "var")

# Plot correlation forecasts
plot(fit.fc, type = "cor")

# Save backcasted and forecasted values as data frame.
fit.fc.df <- as.data.frame(fit.fc)

# Save only forecasted values as data frame.
fit.fc.df <- as.data.frame(fit.fc, backcast = FALSE)

# Add another model, compute model weights and perform a model weighted forecast

# Fit a DCC(1,1) model
fit1 <- bmgarch(panas, parameterization = "DCC", P = 1, Q = 1, meanstructure = "constant")

# Compute model stacking weights based on the last 19 time points (with L = 80)
blist <- bmgarch_list( fit1, fit )
mw <- model_weights(blist, L = 80)

# Weighted forecasts:
w.fc <- forecast(object = blist, ahead = 8, weights = mw)

## End(Not run)

bmgarch documentation built on Sept. 12, 2023, 1:13 a.m.