# Predict method for objects of class ‘nlar’.

### Description

Forecating a non-linear model object of general class ‘`nlar`

’,
including ‘`setar`

’ and ‘`star`

’.

### Usage

1 2 3 4 |

### Arguments

`object` |
An object of class ‘ |

`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. |

### 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:

- naive
No residuals

- MC
Monte-Carlo method, where residuals are taken from a normal distribution, with sd. equal to the residuals sd.

- bootstrap
Residuals are resampled from the empirical residuals from the model.

- block-bootstrap
Same as bootstrap, but residuals are resampled in block, with size

`block.size`

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).

### Value

A ‘`ts`

’ object, or, in the case of MC/bootstrap, a list
containing the prediction (pred) and the forecast standard errors
(`se`

).

### Author(s)

Matthieu Stigler

### 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`

.

A more sophisticated predict function, allowing to do sub-sample rolling
predictions: `predict_rolling`

.

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
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)
legLabels <- c("Observed", "Naive F", "Bootstrap F","Block-Bootstrap F", "MC F")
legend("bottomleft", leg=legLabels, lty=1:5, col=1:5)
``` |