Forecast Performance using Loop
Forecast Performance using Loop
Dear;
I wanted to compare the 1-step ahead mean square prediction errors for an AR(1) and an AR(2) model of Automobile. For this I have written the following:
set f_ar1 = 0.
set f_ar2 = 0.
do i = 100,168
lin(noprint,define=ar1) Automobile 3 i; # constant Automobile {1}
forecast 1 1
# ar1 f_ar1
lin(noprint,define=ar2) Automobile 3 i; # constant Automobile {1 to 2}
forecast 1 1
# ar2 f_ar2
end do i
Then for the calculation of squared prediction errors from the AR(1) and the AR(2), to calculate and display the mean square prediction error for the AR(1) and lines and to calculate and display the mean square prediction error for the AR(2), I have written in RATS the following.
set pe_1 101 169 = (Automobile - f_ar1)**2
set pe_2 101 169 = (Automobile - f_ar2)**2
sta(noprint) pe_1
dis ‘The MSPE from the AR(1) is: ‘ %mean
sta(noprint) pe_2
dis ‘The MSPE from the AR(2) is: ‘ %mean
The upper half of the program ran successfully and even up to the command "sta(noprint) pe_1" its ok. But I am not able to ran the following two commands:
dis ‘The MSPE from the AR(1) is: ‘ %mean
sta(noprint) pe_2
dis ‘The MSPE from the AR(2) is: ‘ %mean
When I press Enter for the command "dis ‘The MSPE from the AR(1) is: ‘ %mean" I got the following message:
## SX19. This Character is Illegal Here
>>>>dis ‘<<<<
The reason I identify is that in my RATS I am not able to write the symbol "(‘)". This symbol I can pasted from manual in Notepad, MS Word and even in this window of software forum. In RATS it is pasted in some different way 70% like the word (a). Even when I copy the (‘) from notepad to RATS it becomes different symbol and if again I copied from RATS to notepad then it will be fine and looks like (‘).
Kindly Help me out how I am able to write this command/symbol.
Further,i also want to compare the 1-step ahead mean square prediction errors for an AR(3) and ARMA(2,3) and ARMA(0,4). Then for adding the MA term in above program what will be the procedure.
A thousands thanks
Waiting your hopeful response.
I wanted to compare the 1-step ahead mean square prediction errors for an AR(1) and an AR(2) model of Automobile. For this I have written the following:
set f_ar1 = 0.
set f_ar2 = 0.
do i = 100,168
lin(noprint,define=ar1) Automobile 3 i; # constant Automobile {1}
forecast 1 1
# ar1 f_ar1
lin(noprint,define=ar2) Automobile 3 i; # constant Automobile {1 to 2}
forecast 1 1
# ar2 f_ar2
end do i
Then for the calculation of squared prediction errors from the AR(1) and the AR(2), to calculate and display the mean square prediction error for the AR(1) and lines and to calculate and display the mean square prediction error for the AR(2), I have written in RATS the following.
set pe_1 101 169 = (Automobile - f_ar1)**2
set pe_2 101 169 = (Automobile - f_ar2)**2
sta(noprint) pe_1
dis ‘The MSPE from the AR(1) is: ‘ %mean
sta(noprint) pe_2
dis ‘The MSPE from the AR(2) is: ‘ %mean
The upper half of the program ran successfully and even up to the command "sta(noprint) pe_1" its ok. But I am not able to ran the following two commands:
dis ‘The MSPE from the AR(1) is: ‘ %mean
sta(noprint) pe_2
dis ‘The MSPE from the AR(2) is: ‘ %mean
When I press Enter for the command "dis ‘The MSPE from the AR(1) is: ‘ %mean" I got the following message:
## SX19. This Character is Illegal Here
>>>>dis ‘<<<<
The reason I identify is that in my RATS I am not able to write the symbol "(‘)". This symbol I can pasted from manual in Notepad, MS Word and even in this window of software forum. In RATS it is pasted in some different way 70% like the word (a). Even when I copy the (‘) from notepad to RATS it becomes different symbol and if again I copied from RATS to notepad then it will be fine and looks like (‘).
Kindly Help me out how I am able to write this command/symbol.
Further,i also want to compare the 1-step ahead mean square prediction errors for an AR(3) and ARMA(2,3) and ARMA(0,4). Then for adding the MA term in above program what will be the procedure.
A thousands thanks
Waiting your hopeful response.
Muhammad Husnain
PhD Scholar (Finance)
Islamabad-Pakistan
PhD Scholar (Finance)
Islamabad-Pakistan
Re: Forecast Performance using Loop
You don't have a ' on your keyboard? It's the standard keyboard ' symbol that you need, not the fancy typographer's quotes. Note, BTW, that you can use either '...' or "..." for strings in RATS.
Re: Forecast Performance using Loop
Thanks for this. I have gotten the MSPE with the "...." strings.
Further,i also want to compare the 1-step ahead mean square prediction errors for an AR(3) and ARMA(2,3) and ARMA(0,4). Then for adding the MA term in above program what will be the procedure.
Guide me about this.
Further,i also want to compare the 1-step ahead mean square prediction errors for an AR(3) and ARMA(2,3) and ARMA(0,4). Then for adding the MA term in above program what will be the procedure.
Guide me about this.
Muhammad Husnain
PhD Scholar (Finance)
Islamabad-Pakistan
PhD Scholar (Finance)
Islamabad-Pakistan
Re: Forecast Performance using Loop
Use BOXJENK rather than LINREG for estimating ARMA models.
Re: Forecast Performance using Loop
Dear Tom Doan:
Thanks for your help but I think I am not able to clear my problem. Let me put in this way.
Basically I want to Select an ARMA Model using Loop, but my objective is TWO fold. I can use the following command for the selection of AR and MA term for the WHOLE sample period (2000:1 to 2014:6 on Monthly basis):
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q,noprint) Textile 2000:5 *
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
It will give me the AIC, SBC for all possible combination of 'p' and 'q' for the whole SAMPLE period.
I want to do the same by changing the SAMPLE period each time. For example, I need to run the above program for the selection of AR and MA for sample of 2000:5 to 2008:5 then same (on same variable) for the sample of 2000:5 to 2008:6. similarly I again need to run the same program for the sample period 2000:5 to 2008:7 and so on up to the end date i.e 2014:6. In this way I can get the combination of 'p' and 'd' for each sub-sample (New sample come by just adding one entry) and I can select the one which is more repeating etc.
I also need to use the above by changing the initial date as well ( Just like the concept of Rolling regression i.e in each sub-sample no of observation will be same)
As per my knowledge, I used the following but failed.
do p = 0,4
do q = 0,4
do i = 70,174
box(constant,ar=p,ma=q,) KSE 5 i
## OP3. This Instruction Does Not Have An Option
>>>>onstant,ar=p,ma=q,)<<<<
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do i
end do q
end do p
Kindly help me in this regard that how it possible in RATS, as I also tried to find it in helping material but did't got.
Thanks
Thanks for your help but I think I am not able to clear my problem. Let me put in this way.
Basically I want to Select an ARMA Model using Loop, but my objective is TWO fold. I can use the following command for the selection of AR and MA term for the WHOLE sample period (2000:1 to 2014:6 on Monthly basis):
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q,noprint) Textile 2000:5 *
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
It will give me the AIC, SBC for all possible combination of 'p' and 'q' for the whole SAMPLE period.
I want to do the same by changing the SAMPLE period each time. For example, I need to run the above program for the selection of AR and MA for sample of 2000:5 to 2008:5 then same (on same variable) for the sample of 2000:5 to 2008:6. similarly I again need to run the same program for the sample period 2000:5 to 2008:7 and so on up to the end date i.e 2014:6. In this way I can get the combination of 'p' and 'd' for each sub-sample (New sample come by just adding one entry) and I can select the one which is more repeating etc.
I also need to use the above by changing the initial date as well ( Just like the concept of Rolling regression i.e in each sub-sample no of observation will be same)
As per my knowledge, I used the following but failed.
do p = 0,4
do q = 0,4
do i = 70,174
box(constant,ar=p,ma=q,) KSE 5 i
## OP3. This Instruction Does Not Have An Option
>>>>onstant,ar=p,ma=q,)<<<<
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do i
end do q
end do p
Kindly help me in this regard that how it possible in RATS, as I also tried to find it in helping material but did't got.
Thanks
Muhammad Husnain
PhD Scholar (Finance)
Islamabad-Pakistan
PhD Scholar (Finance)
Islamabad-Pakistan
Re: Forecast Performance using Loop
When you took out the NOPRINT on the BOXJENK you didn't take out the extra , which is why the program is pointing to the character after that as it can't make sense out of the instruction.
As you have that written, the time periods are on the inner loop. I'm not sure why you would do that. If you want to pick the "best" model for each data range, you would want time to be the outer loop, not the inner one. Note also that the @BJAUTOFIT procedure handles the selection loop automatically.
As you have that written, the time periods are on the inner loop. I'm not sure why you would do that. If you want to pick the "best" model for each data range, you would want time to be the outer loop, not the inner one. Note also that the @BJAUTOFIT procedure handles the selection loop automatically.
Re: Forecast Performance using Loop
Dear;
Thanks for valuable guidance.
I have tried the time in outer loop then it works for me. The following is used for selection of order of ARMA model for forecasting of 176th period. The order which is most repeating in sub samples is selected for final forecasting i.e 176th period. I have opted this as I have no other authenticated way for it. Anyhow you have written the @BJAUTOFIT command. But I am not able to understand this. I got this program from internet written by you, but not able to find it in any detailed manual for my raw level understanding. Is there any detail for this, then kindly share it.
do i = 74,174
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q) Automobile 5 i
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
end do i
For Rolling selection:
do i = 74,174
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q) Automobile i-69 i
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
end do i
Again thanks for this.
Thanks for valuable guidance.
I have tried the time in outer loop then it works for me. The following is used for selection of order of ARMA model for forecasting of 176th period. The order which is most repeating in sub samples is selected for final forecasting i.e 176th period. I have opted this as I have no other authenticated way for it. Anyhow you have written the @BJAUTOFIT command. But I am not able to understand this. I got this program from internet written by you, but not able to find it in any detailed manual for my raw level understanding. Is there any detail for this, then kindly share it.
do i = 74,174
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q) Automobile 5 i
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
end do i
For Rolling selection:
do i = 74,174
do p = 0,4
do q = 0,4
box(constant,ar=p,ma=q) Automobile i-69 i
compute aic = %nobs*log(%rss) + 2*(%nreg)
compute sbc = %nobs*log(%rss) + (%nreg)*log(%nobs)
dis 'Order ' p q 'The aic = ' aic ' and sbc = ' sbc
end do q
end do p
end do i
Again thanks for this.
Muhammad Husnain
PhD Scholar (Finance)
Islamabad-Pakistan
PhD Scholar (Finance)
Islamabad-Pakistan
Re: Forecast Performance using Loop
Those will "work", but I'm not sure what you're going to get from them. Those will produce a great deal of information that won't be easy to handle. @BJAUTOFIT is described in the User's Guide and used in about a dozen textbook examples. For what it sounds like you're doing, this would handle the fixed start regressions (with the obvious change for the rolling sample)
This will show only the time period and the chosen number of AR and MA lags for estimation through that time period.
Code: Select all
do i = 74,174
@bjautofit(pmax=4,qmax=4,constant,noprint,crit=aic) automobile 5 i
disp i %%autop %%autoq
end do i