Learn R Programming

tsDyn (version 0.9-1)

predict: Predict method for objects of class nlar, VAR or VECM

Description

Forecating a non-linear model object of general class nlar, or a linear multivariate VAR / VECM, including setar and star.

Usage

## S3 method for class 'nlar':
predict(object, newdata, n.ahead=1, type=c("naive", "MC", "bootstrap", "block-bootstrap"), nboot=100, ci=0.95, block.size=3, boot1Zero=TRUE,...)	
## S3 method for class 'VAR':
predict(object, newdata, n.ahead=5, ...)	
## S3 method for class 'VECM':
predict(object, newdata, n.ahead=5, ...)

Arguments

object
An object of class nlar; generated by setar() or lstar(). Alternatively, a multivariate object of class VAR or VECM
newdata
Optional. A new data frame to predict from.
n.ahead
An integer specifying the number of forecast steps.
type
Type of forecasting method used. See details.
nboot
The number of replications for type MC or bootstrap.
ci
The forecast confidence interval (available only with types MC and bootstrap).
block.size
The block size when the block-bootstrap is used.
boot1Zero
Whether the first innovation for MC/bootstrap should be set to zero.
...
Currently not used.

Value

  • A ts object, or, in the case of MC/bootstrap, a list containing the prediction (pred) and the forecast standard errors (se).

encoding

latin1

concept

  • VAR
  • VECM
  • Vector autoregressive
  • Forecasts of VAR
  • Prediction of VAR

Details

The forecasts are obtained recursively from the estimated model. Given that the models are non-linear, ignoring the residuals in the 2- and more steps ahead forecasts leads to biased forecasts (so-called naive). Different resampling methods, averaging n.boot times over future residuals, are available:

[object Object],[object Object],[object Object],[object Object]

The MC and bootstrap methods correspond to equations 3.90 and 3.91 of Franses and van Dijk (2000, p. 121). The bootstrap/MC is initiated either from the first forecast, n.ahead=1 (set with boot1zero to TRUE), or from the second only.

When the forecast method is based on resampling, forecast intervals are available. These are obtained simply as empirical ci quantiles of the resampled forecasts (cf Method 2 in Franses and van Dijk, 2000, p. 122).

References

Non-linear time series models in empirical finance, Philip Hans Franses and Dick van Dijk, Cambridge: Cambridge University Press (2000).

See Also

The model fitting functions setar, lstar; or lineVar and VECM.

A more sophisticated predict function, allowing to do sub-sample rlooing predictions: predict_rolling.

Examples

Run this code
x.train <- window(log10(lynx), end = 1924)
x.test <- window(log10(lynx), start = 1925)


### Use different forecasting methods:
mod.set <- setar(x.train, m=2, thDelay=0)
pred_setar_naive <- predict(mod.set, n.ahead=10)
pred_setar_boot <- predict(mod.set, n.ahead=10, type="bootstrap", n.boot=200)
pred_setar_Bboot <- predict(mod.set, n.ahead=10, type="block-bootstrap", n.boot=200)
pred_setar_MC <- predict(mod.set, n.ahead=10, type="bootstrap", n.boot=200)

## Plot to compare results:
pred_range <- range(pred_setar_naive, pred_setar_boot$pred, pred_setar_MC$pred, na.rm=TRUE)
plot(x.test, ylim=pred_range, main="Comparison of forecasts methods from same SETAR")
lines(pred_setar_naive, lty=2, col=2)
lines(pred_setar_boot$pred, lty=3, col=3)
lines(pred_setar_Bboot$pred, lty=4, col=4)
lines(pred_setar_MC$pred, lty=5, col=5)

legend("bottomleft", leg=c("Observed", "Naive F", "Bootstrap F","Block-Bootstrap F", "MC F"), lty=1:5, col=1:5)

Run the code above in your browser using DataLab