predict.larch: Variance forecasting with 'larch' models

View source: R/gets-larch-source.R

predict.larchR Documentation

Variance forecasting with 'larch' models

Description

Generate out-of-sample variance forecasts up to n.ahead steps ahead. Optionally, quantiles of the forecasts are also returned if the argument probs is specified. The forecasts, confidence intervals and quantiles are obtained via simulation. By default, 5000 simulations is used, but this can be changed via the n.sim argument. Also by default, the simulations uses a classical bootstrap to sample from the standardised residuals. To use an alternative set of standardised innovations, for example the standard normal, use the innov argument

Usage

  ## S3 method for class 'larch'
predict(object, n.ahead=12, newvxreg=NULL, newindex=NULL, 
    n.sim=NULL, innov=NULL, probs=NULL, quantile.type=7, verbose = FALSE, ...)

Arguments

object

an object of class 'larch'

n.ahead

integer that determines how many steps ahead predictions should be generated (the default is 12)

newvxreg

a matrix of n.ahead rows and NCOL(vxreg) columns with the out-of-sample values of the vxreg regressors

newindex

NULL (default) or the date-index for the zoo object returned by predict.larch. If NULL, then the function uses the in-sample index to generate the out-of-sample index

n.sim

NULL (default) or an integer, the number of replications used for the generation of the forecasts. If NULL, the number of simulations is determined internally (usually 5000)

innov

NULL (default) or a vector of length n.ahead * n.sim containing the standardised errors (i.e. mean zero and unit variance) used for the forecast simulations. If NULL, then a classic bootstrap procedure is used to draw from the standardised in-sample residuals

probs

NULL (default) or a vector with the quantile-levels (values strictly between 0 and 1) of the forecast distribution. If NULL, then no quantiles are returned

quantile.type

an integer between 1 and 9 that selects which algorithm to be used in computing the quantiles, see the argument type in quantile

verbose

logical with default FALSE. If TRUE, then additional information (typically the quantiles and/or the simulated series) used in the generation of forecasts is returned. If FALSE, then only the forecasts are returned

...

additional arguments

Details

No details for the moment.

Value

a vector of class zoo containing the out-of-sample forecasts, or a matrix of class zoo containing the out-of-sample forecasts together with additional information (e.g. the prediction-quantiles)

Author(s)

Genaro Sucarrat, https://www.sucarrat.net/

See Also

larch

Examples

##Simulate some data:
set.seed(123)
e <- rnorm(40)

##estimate log-ARCH(1) model:
mymod <- larch(e, arch=1)

##generate out-of-sample forecasts:
predict(mymod)

##same, but return also selected quantiles:
predict(mymod, probs=c(0.10,0.90))

##same, but using standard normals (instead of bootstrap) in the simulations:
n.sim <- 2000
n.ahead <- 12 #the default on n.ahead
predict(mymod, probs=c(0.10,0.90), n.sim=n.sim, innov=rnorm(n.ahead*n.sim))

##make x-regressors:
x <- matrix(rnorm(40*2), 40, 2)

##estimate log-ARCH(1) model w/covariates:
mymod <- larch(e, arch=1, vxreg=x)

##predict up to 5 steps ahead, setting x's to 0 out-of-sample:
predict(mymod, n.ahead=5, newvxreg=matrix(0,5,NCOL(x)))


gets documentation built on Sept. 11, 2024, 9:03 p.m.