Description Usage Arguments Details Value Author(s) Examples
View source: R/midas_r_methods.R
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
object |
midas_r object |
newdata |
a named list containing future values of mixed frequency regressors. The default is |
se |
logical, if |
level |
confidence level for prediction intervals |
fan |
if TRUE, level is set to seq(50,99,by=1). This is suitable for fan plots |
npaths |
the number of samples for simulating prediction intervals |
method |
the forecasting method, either |
insample |
a list containing the historic mixed frequency data |
show_progress |
logical, if |
add_ts_info |
logical, if |
... |
additional arguments to |
Given future values of regressors this function combines the historical values used in the fitting the MIDAS regression model and calculates the forecasts.
an object of class "forecast"
, a list containing following elements:
method |
the name of forecasting method: MIDAS regression, static or dynamic |
model |
original object of class |
mean |
point forecasts |
lower |
lower limits for prediction intervals |
upper |
upper limits for prediction intervals |
fitted |
fitted values, one-step forecasts |
residuals |
residuals from the fitted model |
x |
the original response variable |
The methods print
, summary
and plot
from package forecast
can be used on the object.
Vaidotas Zemlys
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 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*h)
##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")
##Use print, summary and plot methods from package forecast
fmr <- forecast(mr, list(trend = trendn, x = xn), method = "static")
fmr
summary(fmr)
plot(fmr)
|
Loading required package: sandwich
Loading required package: optimx
Point Forecast
2012 0.04798328
2013 0.04638829
2014 0.04609471
Point Forecast
2012 0.04598409
2013 0.04446394
2014 0.04355180
Point Forecast
2012 0.04798328
2013 0.04638829
2014 0.04609471
Forecast method: MIDAS regression forecast (static)
Model Information:
MIDAS regression model
model: y ~ trend + fmls(x, 23, 12, nealmon)
(Intercept) trend x1 x2 x3
0.0421355 -0.0002936 -0.2333520 0.4611676 -0.0250372
Function optim was used for fitting
Error measures:
ME RMSE MAE MPE MAPE MASE
Training set 2.266363e-07 0.008224211 0.006657488 5.453882 43.69982 0.2984747
ACF1
Training set 0.06705183
Forecasts:
Point Forecast
2012 0.04798328
2013 0.04638829
2014 0.04609471
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.