mpiktas / midasr

R package for mixed frequency time series data analysis.
http://mpiktas.github.io/midasr/
Other
74 stars 34 forks source link

Forecast dates with no new data incorrect? #46

Closed Knixd closed 7 years ago

Knixd commented 8 years ago

Hello,

The following is a Midas regression that has no new data as per p.27 of the midasr user guide. This example code is largely from the example in the forecast function.

To the best of my understanding, the forecasted time references are incorrect.

I've set the lags back 3 horizon's worth of 12 higher frequency lags (3*12) with the understanding that together with the forecast function I am forecasting doing one step ahead forecasts three times using data up to Yt-3 to forecast until Yt. Essentially, forecasting Yt-2, Yt-1, and Yt. Note that the Midas user guide only does 1 horizon with no new data.

In the terms of this code, Yt is 2011.

Because of my forecast setup, I expected the dates of the forecasted values to be 2010, 2011, and 2012. They're not. They're 2012, 2013, 2014. From checking the algebraic equation on p. 27 in the Midas User Guide and their subsequent example I can't find any reason why the dates would be 2012, 2013, 2014.

By setting my high-frequency lags back by the suggested (frq*h) amount and receiving 2012-20134 forecasts, wouldn't this infer I'm using Yt-3 to forecast Yt+1, Yt+2, and Yt+3 rather than Yt-2, Yt-1, and Yt?

It's very possible I'm misunderstanding something. Ultimately I need to know how to forecast a Q4 and a Q1 variable with data up to Q3 and an AR element (dynamic).

    set.seed(1234)
    data("USrealgdp")
    data("USunempr")

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

    #High Frequency Variable's Frequency
    frq<-12

    ##Forecast horizon
    h <- 3

    ##Declining unemployment
    xn <- rep(-0.1, frq*h)

    ##New trend values
    trendn <- length(y) + 1:h

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

    forecast(mr.dyn, list(trend = trendn, x = rep(NA,frq*h)), method = "dynamic")

Gives the forecast output of

    #Point Forecast
    2012     0.03654885
    2013     0.01834644
    2014     0.01803171
vzemlys commented 8 years ago

Your estimation sample ends at 2011, since this is the last value in response variable. So the forecast assumes that the forecasts start at 2012, since this is the first value not available for the estimation. The forecasts for 2011 and 2010 are actually the in-sample predicted values. Since you've lagged all the predictor variables, your forecasts do not depend on the forecasts of predictor variables, i.e. you get the same result for:

forecast(mr.dyn, list(trend = trendn, x = rep(NA,frq*h)), method = "dynamic")

and

forecast(mr.dyn, list(trend = trendn, x = rep(NA,frq*h)), method = "static")

Hope this clears things a bit.

PS. Sorry for late reply. Write me directly to my maintainer email for faster response.