Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ARMA model rolling window dynamic forecast (STATA 12)

    I use the BOX Jenkins methodology to forecast US quarterly GDP and I want dynamic forecasts (4 quarters ahead)
    The regular predict command is fine but I would like to use a rolling and recursive window forecast combined with the dynamic forecast

    Here are the commands that I have so far (first part is just the regular way the predict command is implemented)
    install estatsto and freduse if not installed yet, commands provided


    ** group project "Topics in Econometrics Semester B 2014 HK"
    **forecasting US real quarterly GDP
    clear
    set more off
    **define working directory (use online Dropbox)

    **install estatso and freduse program if not installed (delete the stars in the following line)
    **ssc install estatsto
    **ssc install freduse
    **open relevant file
    freduse GDPC96, clear
    gen q=quarter(daten)
    drop daten
    gen time=tq(1947q1)+_n-1
    format time %tq
    gen t=_n
    tsset t
    gen lGDP=log(GDP)
    **generate linear, quadratic and cubic trend variable (may not all be needed)
    gen trend=_n
    gen trend2=trend^2
    **engage in forecast of the AR2(and for completeness for AR3 as well)
    local estend 260
    local fbegin 261
    arima lGDP trend trend2 if tin(,`estend'), arima(2,0,0) vce(robust)
    predict fcGDPAR2, dynamic(261)
    predict fce, residual
    **obtain FC error interval only for AR2 which is superior
    predict fcGDPerr, mse dynamic(261)
    gen fcGDPupper=fcGDPAR2+1.96*sqrt(fcGDPerr) if tin(`fbegin',)
    gen fcGDPlower=fcGDPAR2-1.96*sqrt(fcGDPerr) if tin(`fbegin',)
    list fcGDPupper lGDP fcGDPAR2 fcGDPlower if tin(`fbegin',)
    tsline lGDP fcGDPAR2 fcGDPupper fcGDPlower in 230/268, legend(label(1 "lGDP") label(2 "dynamic FC") label(3 "upper bound") label(4 "lower bound")) saving(lGDPintFC1.png, asis replace)



    ************************************************** ************************************************** ************************************************** *****
    ** attempts for using rolling and recursive window (this command works, but is only 1 step ahead, I would like to get dynamic forecasts)
    gen recursiveFC= .
    gen rollingFC= .
    forvalues i = 200(1)268 {
    reg lGDP trend trend2 L(1/2).lGDP if t<`i', robust
    predict p if t==`i'
    replace recursiveFC = p if t==`i'
    drop p
    }

    **for rolling window
    forvalues i = 200(1)268 {
    reg lGDP trend trend2 L(1/2).lGDP if t>=`i'-200 & t<`i', robust
    predict p if t==`i'
    replace rollingFC = p if t==`i'
    drop p
    }

    tsline lGDP rollingFC recursiveFC in 230/268


    I need help because I cannot figure out how to implement the dynamic forecast =predict fcGDPAR2, dynamic

    The regular command needs a start date, but I have a time varying. Simply implementing `i' instead of a start date does not work.



    Thanks for any advice. Help on how to include Interval forecast bands that grow over time (not just the 1 step ahead forecast error) would be nice as well.


    Alex


  • #2
    Dear Alexander,

    I am currently exploring the possibility of conducting time series rolling forecasts, much like you. Have you managed to find a solution to this challenge?

    If so, would it be possible for you to share some sample code? I would greatly appreciate your assistance.

    Thank you for taking the time to read my message.

    Warm regards,
    Hsin-Yun

    Comment

    Working...
    X