Page 1 of 1
RECURSIVE FORECSATS
Posted: Wed May 03, 2017 10:28 am
by Deepika
Hi Tom
I am trying to obtain recursive forecasts for inflation (variable wi in file) from an ARIMA estimation. my sample period is 1984: to 2017:3. i want to obtain 3 step ahead in sample forecasts where my inital sample would be 1984:4 to 1996:1 and then obtain forecast for 1996:4. similarly in the next step the sample is 1984:4 to 1996:2 and obtain forecast for 1996:5. when i used the following code the program gives me an error
## SC1. Expected Supplementary Card (# ....) Here
>>>>g<<<<
OPEN DATA "C:\UsersData\Deepika\ECONOMETRIC WORK FOR PHD ISSUE 1\ARIMA.xlsx"
CALENDAR(M) 1984:4
DATA(FORMAT=XLSX,ORG=COLUMNS,SHEET="Sheet4") 1984:04 2017:03 WPI FOOD wi fi
* ARMA(1,3)
*
boxjenk(diff=1,constant,ar=1,ma=3,print) wi 1984:4 1996:3
@regcorrs(dfc=%narma,number=20,qstats,report,$
method=burg,title="ARMA(1,3) model diagnostics")
boxjenk(constant,define=ar1ma3eq,ar=1,ma=3,noprint) wi * 1996:3
do time=1996:4,2017:3
boxjenk(noprint,diff=1,constant,define=ar1ma3eq,ar=1,ma=3) wi * time-3
uforecast(equation=ar1ma3eq,static) forecast_ar1ma3 time time
end do
my data file is attached for reference.
regards
deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 10:59 am
by TomDoan
What you posted couldn't possibly have created that error message if you run it correctly (select all then run).
I'm not sure what a 3-step ahead "static" forecast means in the context of an ARIMA model. You definitely don't want to suddenly start forecasting an ARIMA model 3 steps beyond the end of the estimation range because you need to generate the residuals in the intervening periods for the MA part. Is there a reason to withhold the actual data from the estimation, but then use it for computing forecasts?
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 11:46 am
by Deepika
Hi Tom
thanks for a quick reply. but when i run this together and add print in the uforecast command then what i get is actuals and instead of forecast values what i get is NA.
i want to generate 3 month (as i am working with monthly data) ahead forecasts as this inflation series will be used as expected inflation in my VAR model. this is in line with few papers which i have referred to. one of the example is "Determination of inflation in an open economy Phillips curve framework: the case of developed and developing Asian countries", Macroeconomics and Finance in Emerging Market, 2010 - Taylor & Francis.
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 11:55 am
by TomDoan
Which is the point I was making. You can't just jump ahead three steps and do a "static" forecast because there are no residuals (hence the NA's). Almost certainly (given the description of what you're doing) you want to do three step dynamic forecasts and save the last one only. See
https://estima.com/docs/RATS%209%20User ... f#page=187
(spilling over onto the top of the next page).
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:17 pm
by Deepika
Thanks Tom. But in case of rolling forecast the initial sample keeps changing every time but i want recursive forecasts where my initial sample would be fixed at 1984:4 and every time i would expand my window by one time period. how would the code change then? sorry but i have got confused. thanks for helping
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:22 pm
by TomDoan
Then fix the front end of the estimation range. If you read the whole page, the first example has a fixed start of the estimation range, and then the next one has a fixed window.
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:35 pm
by Deepika
Thank you so much Tom. i have rewriiten thhe code. it seems to work fine. could you pls check whether what i have done is correct. i would be grateful.
Code: Select all
OPEN DATA "C:\UsersData\Deepika\ECONOMETRIC WORK FOR PHD ISSUE 1\ARIMA.xlsx"
CALENDAR(M) 1984:4
DATA(FORMAT=XLSX,ORG=COLUMNS,SHEET="Sheet4") 1984:04 2017:03 WPI FOOD wi fi
* ARMA(1,3)
*
boxjenk(diff=1,constant,ar=1,ma=3,print) wi 1984:4 1996:3
@regcorrs(dfc=%narma,number=20,qstats,report,$
method=burg,title="ARMA(1,3) model diagnostics")
boxjenk(constant,diff=1,define=ar1ma3eq,ar=1,ma=3,noprint) wi * 1996:3
*
do time=1996:3,2016:12
boxjenk(constant,diff=1,define=ar1ma3eq,ar=1,ma=3,noprint) wi * time
uforecast(equation=ar1ma3eq,print) forecast_ar2ma17 time+1 time+3
end do
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:48 pm
by TomDoan
Not quite---the UFORECAST will keep overwriting the forecasts (this periods 3 step forecasts will be overwritten by next period's 2-step and the next period's 1-step). On the second page of the part I told you to read, it tells you how to save just the final step. You also need to decide what period you want to associate with that value: is expected inflation at 1987:1 the expected inflation FOR period itself 1987:1 or is it the expected inflation for three periods out starting AT 1987:1? If the latter, you would save it in entry TIME and in the former, TIME+3.
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:54 pm
by Deepika
The expected inflation for 1987:1 would be expected inflation for 1987:1 itself and not for 3 periods. what i dont understand in the code on the second page is linreg(noprint) logrsales regend-59 regend. why -59?
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 12:57 pm
by TomDoan
That's for rolling samples. You're not doing rolling samples. That has nothing to do with saving the forecasts.
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 1:14 pm
by Deepika
Tom could you please check is it ok now? I am really thankful for your help
OPEN DATA "C:\UsersData\Deepika\ECONOMETRIC WORK FOR PHD ISSUE 1\ARIMA.xlsx"
CALENDAR(M) 1984:4
DATA(FORMAT=XLSX,ORG=COLUMNS,SHEET="Sheet4") 1984:04 2017:03 WPI FOOD wi fi
* ARMA(1,3)
*
boxjenk(diff=1,constant,ar=1,ma=3,print) wi 1984:4 1996:3
@regcorrs(dfc=%narma,number=20,qstats,report,$
method=burg,title="ARMA(1,3) model diagnostics")
boxjenk(constant,diff=1,define=ar1ma3eq,ar=1,ma=3,noprint) wi * 1996:3
*
do time=1996:3,2016:12
boxjenk(constant,diff=1,define=ar1ma3eq,ar=1,ma=3,noprint) wi * time
uforecast(equation=ar1ma3eq,print) forecast_ar1ma3 time+1 time+3
compute forecast_ar1ma3(time+3)=forecast_ar1ma3(time+3)
end do
What i get after running this code is the following output. i believe what is relevant for me are the first obsevations in each group?
Entry WI
1996:04 4.655990915
1996:05 4.526275472
1996:06 4.619243753
Entry WI
1996:05 3.146526604
1996:06 3.272882125
1996:07 3.089770181
Entry WI
1996:06 3.759946811
1996:07 3.566730534
1996:08 3.694930743
Entry WI
1996:07 3.331555996
1996:08 3.464117466
1996:09 3.314116588
Entry WI
1996:08 4.552966815
1996:09 4.406340921
1996:10 4.522644823
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 1:28 pm
by TomDoan
This is pointless (it's saying something is equal to itself).
compute forecast_ar1ma3(time+3)=forecast_ar1ma3(time+3)
You have to use a different name for the target series for the 3 step alone:
And no, the first number in each batch is the 1-step ahead forecast. The third number is the 3-step ahead forecast.
I hope you realize that you can't estimate the ARIMA model actually starting in 1984:4 since you have both a difference and a AR term that needs initial observations. The BOXJENK with the * as the start will begin in 1984:6.
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 10:11 pm
by Deepika
Yes i do understand that BJ will start from 1984:6 but when i choose another name then i get an error
uforecast(equation=ar1ma3eq,print) forecast_ar1ma3 time+1 time+3
compute forecast_ar1ma3(time)=forecast_ar1ma3(time+3)
end do
the error is as follows:
## MAT13. Store into out-of-range FORECAST_AR1MA3(142)
The Error Occurred At Location 187, Line 4 of loop/block
32765480 Position 416
Regards
Deepika
Re: RECURSIVE FORECSATS
Posted: Wed May 03, 2017 11:08 pm
by TomDoan
You get an error if you put in 1984:6 instead of 1984:4 on the start of the estimation range?
That's what the CLEAR instructions are for in those examples. You might want to read that section more carefully---every one of your questions since I posted the page reference has been covered (usually in detail) on that two page section.
Re: RECURSIVE FORECSATS
Posted: Thu May 04, 2017 4:34 am
by Deepika
Thank you Tom. Igot it now
Regards
Deepika