i_predict: Iteratively predicted values based on a model object

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Function to iteratively predict/forecast from specified model object, primarily for predicting models that include lagged dependent variables

Usage

1
i_predict(object, newdata, ...)

Arguments

object

a model object for predictions.

...

additional arguments affecting the predictions.

Details

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

Value

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.

Note

Function not yet tested against all possible predict methods.

Author(s)

David Mitchell <david.p.mitchell@homemail.com.au>

See Also

predict, predict.lm, predict.glm.

Examples

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

mitcda/predict.utils documentation built on May 15, 2019, 4:27 p.m.