Function to iteratively predict/forecast from specified
model object, primarily for predicting models that include lagged dependent variables
a model object for predictions.
additional arguments affecting the predictions.
This function provides a general approach to the problem of producing forecasts, or out of sample predictions, from (linear) models containing lagged dependent variables. Other approaches to producing rolling or iterative forecasts include: Variations on rolling forecasts and Iteratively forecasting dyn models.
Most prediction methods that are similar to those for linear models have an argument
newdata specifying the first place to look for explanatory variables to be used for prediction. Some considerable attempts are made to match up the columns in
newdata to those used for fitting, for example that they are of comparable types and that any factors have the same level set in the same order (or can be transformed to be so).
The form of the value returned by
i_predict depends on the class of its argument. See details of the particular methods for details of what is produced by that method.
Function not yet tested against all possible
David Mitchell <email@example.com>
1 2 3 4 5 6 7 8 9 10 11 12
data(AvData); lm.AirFrgt <- lm(log(Freight.TKM) ~ log(A2304402X) + log(Aircraft.Departures) + dQ2 + dQ3 + dQ4 + dPilot.Sep89 + dPilot.Dec89 + dPilot.Mar90 + lag(log(Freight.TKM)), data = AvData); data(FcstData); FcstData <- transform(FcstData, A2304113C = splice_series(A2304113C, Fcst_Real_GDP_level), A2304402X = splice_series(A2304402X, Fcst_Real_GDP_level), Aircraft.Departures = splice_series(Aircraft.Departures, Fcst_Aircraft.Departures)); AvFcsts <- exp(i_predict(lm.AirFrgt, newdata=Fcst.AvData, interval="prediction")); tail(AvFcsts);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.