##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)))
Run the code above in your browser using DataLab