predict.ardl: Predict method for ARDL model fits

View source: R/predict.R

predict.ardlR Documentation

Predict method for ARDL model fits

Description

Makes predictions based on fitted ARDL models, extending the generic function predict for use with ardl. It is designed to take advantage of lags of the dependent variable (AR components) from the fitted model and new values of the independent variable(s) to calculate predictions.

Usage

## S3 method for class 'ardl'
predict(object, newdata, ...)

Arguments

object

A fitted model of class ardl.

newdata

A time series object (ts, zoo, zooreg) or a data.frame containing the new values of the independent variables x required to make predictions.

...

further arguments passed to or from other methods.

Details

predict.ardl works recursively to calculate predictions based on y_{t-1}, ..., y_{t-p} values contained within a fitted model, and new values of x_{T+1}, ..., x_{T+h}, where T denotes the last observation of t from the original data and h is the number of new observations that will be used to calculate predictions. These are supplied through the newdata argument. It is important to note that for a given prediction \hat{y}_{T+1}, the independent variables provided through newdata, are expected to follow consecutively from the last observation x_{T} used to create the model, i.e. x_{T+1}, ..., x_{T+h}, with no gaps. If a time series object is passed to the function, the frequency and whether the observations follow consecutively will be checked.

Value

predict.ardl returns values for \hat{y}_{T+1}, ..., \hat{y}_{T+h} equal in length to the number of rows in newdata, as a vector.

Calculation example

We want to predict \hat{y}_{T+1} given an ARDL(2,2) model:

\hat{y}_{T+1} = Z \boldsymbol{\beta}

where Z is our design matrix and \beta is a vector of our model coefficients. We need 2 lags for our dependent and independent variables: y_T, y_{T-1} and X_T, X_{T-1}. Plus, X_{T+1} (from newdata), which in our design matrix is equivalent to time t in our original model:

Z = \left[ \begin{array}{c|cccccc} & \mathbf{c} & \mathbf{y_{t-1}} & \mathbf{y_{t-2}} & \mathbf{x_t} & \mathbf{x_{t-1}} & \mathbf{x_{t-2}} \\ \hline T\!+\!1 & 1 & y_{T} & y_{T-1} & x_{T+1} & x_{T} & x_{T-1} \end{array} \right]

We proceed to the next iteration, predicting \hat{y}_{T+2}, using the previously calculated value of \hat{y}_{T+1}:

Z = \left[ \begin{array}{c|cccccc} & \mathbf{c} & \mathbf{y_{t-1}} & \mathbf{y_{t-2}} & \mathbf{x_t} & \mathbf{x_{t-1}} & \mathbf{x_{t-2}} \\ \hline T\!+\!2 & 1 & y_{T+1} & y_{T} & x_{T+2} & x_{T+1} & x_{T} \end{array} \right]

Iteration continues until we've calculated all the necessary values of \hat{y}_{T+h} for newdata.

Author(s)

Kleanthis Natsiopoulos, klnatsio@gmail.com

Daniel Finnan, dan@custom-made.org.uk

See Also

ardl

Examples

data(denmark)
## Estimate an ARDL(2,1,2,1,1) model, using a subset of the denmark data
ardl_21211 <- ardl(LRM ~ LRY + LPY + IBO + IDE, data = denmark,
                   order = c(2,1,2,1,1),
                   start = "1974 Q1", end = "1986 Q2")
## Make predictions based on the remainder of the denmark data not used in
## training the model
predict_data <- window(denmark, start = "1986 Q3", end = "1987 Q3")
## Drop the dependent variable, since we're predicting it
predict_data <- predict_data[, c("LRY", "LPY", "IBO", "IDE")]
predictions <- predict(ardl_21211, predict_data)

## Estimate a ARDL(4,4,4,4) model with a linear trend and dummies
## Create dummies
d_74Q1_75Q3 <- ifelse(time(denmark) >= "1974 Q1" & time(denmark) <= "1975 Q3", 1, 0)
# Add them to the data
denmark_dums <- cbind(denmark, d_74Q1_75Q3)
## Estimate the model
ardl_4444 <- ardl(LRM ~ LRY + LPY + IBO + trend(LRM) | d_74Q1_75Q3,
                  data = denmark_dums,
                  order = c(4,4,4,4),
                  start = "1974 Q1", end = "1986 Q2")
## Take the remaining data not used in training the model
predict_data <- window(denmark_dums, start = "1986 Q3", end = "1987 Q3")
## Drop the dependent variable
predict_data <- predict_data[, c("LRY", "LPY", "IBO", "d_74Q1_75Q3")]
## Compute the predictions
predictions <- predict(ardl_4444, predict_data)


ARDL documentation built on May 10, 2026, 9:06 a.m.