Learn R Programming

midasr (version 0.2)

forecast: Forecast MIDAS regression

Description

Forecasts MIDAS regression given the future values of regressors. For dynamic models (with lagged response variable) there is an option to calculate dynamic forecast, when forecasted values of response variable are substituted into the lags of response variable.

Usage

forecast(object, ...)

## S3 method for class 'midas_r': forecast(object, newdata = NULL, method = c("static", "dynamic"), insample = get_estimation_sample(object), ...)

Arguments

object
midas_r object
newdata
newdata
method
the forecasting method, either "static" or "dynamic"
insample
a list containing the historic mixed frequency data
...
additional arguments, not used

Value

  • a vector of forecasts

Details

Given future values of regressors this function combines the historical values used in the fitting the MIDAS regression model and calculates the forecasts.

Examples

Run this code
data("USrealgdp")
data("USunempr")

y <- diff(log(USrealgdp))
x <- window(diff(USunempr), start = 1949)
trend <- 1:length(y)

##24 high frequency lags of x included
mr <- midas_r(y ~ trend + fmls(x, 23, 12, nealmon), start = list(x = rep(0, 3)))

##Forecast horizon
h <- 3
##Declining unemployment
xn <- rep(-0.1, 12*3)
##New trend values
trendn <- length(y) + 1:h

##Static forecasts combining historic and new high frequency data
forecast(mr, list(trend = trendn, x = xn), method = "static")

##Dynamic AR* model
mr.dyn <- midas_r(y ~ trend + mls(y, 1:2, 1, "*")
                   + fmls(x, 11, 12, nealmon),
                  start = list(x = rep(0, 3)))

forecast(mr.dyn, list(trend = trendn, x = xn), method = "dynamic")

Run the code above in your browser using DataLab