Quantcast
Channel: EViews
Viewing all articles
Browse latest Browse all 24088

Automatic ARMA selection

$
0
0
Hello!
I want to change the program beacuse I need a regression without constant. I stablished a conditional, but it does't work.
Code:

'Create some data. Delete these first few lines if you want to run on your existing workfile.

series y_SW =0
copy etec y_SW


'Program that calculates the "best" ARMA specification for an equation. Edit the variables below to match your particular data/setup.

%eqname = "ciclo_SW" 'name of equation object that will be used.
%maxAR = "4" 'maximum number of AR terms
%maxMA = "4" 'maximum number of MA terms
%dep = "Y_SW" 'dependent variable
%regs = "C " 'independent variables
%criterion = "@schwarz" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxAR = @val(%maxAR)
!maxMA = @val(%maxMA)


close {%eqname}


'create table for storing critical values.
%matname = "crits_SW"
if @isobject(%matname) then
%matname = "__crits_SW"
if @isobject(%matname) then
delete {%matname}
endif
endif
table(!maxar+2,!maxma+2) {%matname}
{%matname}(1,1) = "AR / MA"
{%matname}.setlines(1) +b
{%matname}.setlines(a) +r

'set sample
smpl @all

!mincrit = 1e12 'set the minimum to an artificially large value to begin

'estimate the models
%arstring = ""
for !i=0 to !maxar
'build up string for AR terms.
if !i>0 then
%arstring = %arstring + " ar(" + @str(!i) + ")"
endif

%mastring = ""
for !j=0 to !maxma
'build up string for MA terms
if !j>0 then
%mastring = %mastring + " ma(" + @str(!j) + ")"
endif

'estimate equation
if %arstring="ar(1)" or %arstring="ar(2)" or %arstring="ar(3)" or %arstring="ar(4)" or %mastring="ma(1)" or %mastring="ma(2)" or %mastring="ma(3)" or %mastring="ma(4)" then
equation {%eqname}.ls(arma=cls, optmethod=legacy) {%dep} {%arstring}{%mastring}
endif

if %arstring="ar(0)" and %mastring="ma(0)" then
equation{%eqname}.ls(arma=cls, optmethod=legacy) {%dep} {%regs}
endif
'capture criterion
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
next
next

I have an error because %eqname is undeterminated or undifined. I think last conditionals isn't correct but I don't know why.



Viewing all articles
Browse latest Browse all 24088

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>