1-Got it!
2- we can show it like this (p,d,q)(P,D,Q) in this code. how can do this
ARIMASel (Automatic ARIMA selection)
Moderators: EViews Gareth, EViews Moderator, EViews Esther
Re: ARIMASel (Automatic ARIMA selection)
Hi all
Is there a way to regress a variable, where the lags on the independent variables are selected automatically, according to the SIC or AIC or HQ?
I modified an autoARMA code to look as follows, but the problem is that the code selects the best lag and adds it, but does not include the lags before that.
That is, i would have, say: GDP C EXPORTS(-6). Obviously I would like it to include all the lags from -1 to -6- Any idea of how to do this? My code is as below:
Any help would be appreciated!
Is there a way to regress a variable, where the lags on the independent variables are selected automatically, according to the SIC or AIC or HQ?
I modified an autoARMA code to look as follows, but the problem is that the code selects the best lag and adds it, but does not include the lags before that.
That is, i would have, say: GDP C EXPORTS(-6). Obviously I would like it to include all the lags from -1 to -6- Any idea of how to do this? My code is as below:
%eqname = "fore" 'name of equation object that will be used.
%dep = "y1_ind" 'dependent variable
%maxlag = "6" 'maximum number of AR terms
%maxlagabs="6" 'maximum number of AR terms (absolute)
'%maxMA = "5" 'maximum number of MA terms
%regs = "C " 'independent variables
%criterion = "@schwarz" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn
!maxlag = @val(%maxlag)
!maxlagabs=@val(%maxlagabs)
'!maxMA = @val(%maxMA)
close {%eqname}
'set sample
smpl @first+!maxlagabs @last
!mincrit = 1e12 'set the minimum to an artificially large value to begin
'estimate the models
%lagstring = ""
for !i=0 to !maxlag
'build up string for lag terms.
if !i>0 then
%lagstring = "dlog("+ %var+"(-" + @str(!i) + "))"
endif
smpl 1980m1 %end
equation {%eqname}.ls dlog({%dep}) {%regs} {%lagstring} '{%mastring}
'capture criterion
if @upper(%criterion) = "@AIC" then
!crit = {%eqname}.@aic
endif
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
if @upper(%criterion) = "@HQ" then
!crit = {%eqname}.@hq
endif
'compare criterion
if !crit < !mincrit then
!mincrit = !crit
!bestlag = !i
'!bestMA = !j
%bestlagstr = %lagstring 'store the best lag string
endif
next
equation {%eqname}_{%var}.ls dlog({%dep}) {%regs} {%bestlagstr} '{%bestMAstr}
for !i= 0 to !maxlag
'build up string for AR terms.
if !i>0 then
%lagstring = "dlog("+ %var+"(-" + @str(!i) + "))"
endif
'show {%eqname}
'show {%matname}
smpl 2002m1 %forend
{%var} = @nan({%var},0)
'smpl if {%dep} = 0
{%eqname}.forecast {%dep}_f
series rm_{%var} = @rmse({%dep},{%dep}_f)
smpl %beg %forend
'plot @pca({%var}_f) @pca({%var})
next
Any help would be appreciated!
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ARIMASel (Automatic ARIMA selection)
Code: Select all
if !i>0 then
%lagstring = "dlog("+ %var+"(-1 to -" + @str(!i) + "))"
endif
Follow us on Twitter @IHSEViews
Re: ARIMASel (Automatic ARIMA selection)
Hi Gareth
Thanks for your help.
I put in in the first loop where the code exists, but I get the error message "-1 TO -1 is not a valid index for variable name in "EQUATION {%EQNAME}.LS DLOG(Y1) C DLOG(VARIABLE NAME(-1 TO -1))"
As far as I understand, the equation is trying to read the -1 TO -1 as part of the variable name, and getting confused.
Any suggestions
Thanks for your help.
I put in in the first loop where the code exists, but I get the error message "-1 TO -1 is not a valid index for variable name in "EQUATION {%EQNAME}.LS DLOG(Y1) C DLOG(VARIABLE NAME(-1 TO -1))"
As far as I understand, the equation is trying to read the -1 TO -1 as part of the variable name, and getting confused.
Any suggestions
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ARIMASel (Automatic ARIMA selection)
Ah, I missed the dlog part.
You'll have to build up the full lag string manually
You'll have to build up the full lag string manually
Follow us on Twitter @IHSEViews
Re: ARIMASel (Automatic ARIMA selection)
Hi Gareth
Does that mean that one cannot find the best lag according to an information criteria, and then just add lags going back to -1 automatically through a loop? So say the code identifies the best lag as -4, can we include code that says "For !maxlag back to -1, add to the regression"?
Thanks
Does that mean that one cannot find the best lag according to an information criteria, and then just add lags going back to -1 automatically through a loop? So say the code identifies the best lag as -4, can we include code that says "For !maxlag back to -1, add to the regression"?
Thanks
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ARIMASel (Automatic ARIMA selection)
The problem is that the code isn't identifying cummulative lags - it is just finding the best single lag length. I presume you want to run all lags up to the lag length.
Follow us on Twitter @IHSEViews
Re: ARIMASel (Automatic ARIMA selection)
Correct. So whichever is the best single lag length, then run all the lags up to that.
Although I see your point, we are identifying the single best lag length and then throwing it out the window by just adding other lags.
Is there a way to automatically code to find that best cumulative lags? Possibly by a loop that adds lags and then tests the SIC, then stops when the SIC reaches its max?
Although I see your point, we are identifying the single best lag length and then throwing it out the window by just adding other lags.
Is there a way to automatically code to find that best cumulative lags? Possibly by a loop that adds lags and then tests the SIC, then stops when the SIC reaches its max?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ARIMASel (Automatic ARIMA selection)
Yes, you'll have to build up the full lag string manually, like in this example (with the AR terms):
viewtopic.php?f=15&t=1175
viewtopic.php?f=15&t=1175
Follow us on Twitter @IHSEViews
Re: ARIMASel (Automatic ARIMA selection)
Thanks. I figured it out, it was a case of adding %lagstring to [code]%lagstring = %lagstring + "dlog("+ %var+"(-" + @str(!i) + "))"[\code]
Is there a way to specify including variables if they show p-value significance? Or barring that, a minimum lag length? While the code worked, some of the equations were throwing out equations without any lags, just the constant.
Is there a way to specify including variables if they show p-value significance? Or barring that, a minimum lag length? While the code worked, some of the equations were throwing out equations without any lags, just the constant.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: ARIMASel (Automatic ARIMA selection)
When you write the for loop for the lags, don't start at 0 lags
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 11 guests