Page 1 of 1

Manual backwards stepwise routine

Posted: Fri Jan 23, 2009 9:19 am
by EViews Gareth

Code: Select all


'create some data - 20 X variables and a Y variable that depends upon X11-X15.
'X variables are put into a group called XS

create u 1000
rndseed 1

group xs
group g
for !i=1 to 20
   series x!i=nrnd
   %name="x"+@str(!i)
   xs.add {%name}
   g.add {%name}
next

series y = nrnd + 3
for !i=11 to 15
   y = y + !i*x{!i}
next


'perform backwards stepwise regression - first run a model with all Xs, then remove Xs one at a time based upon tstat.

equation e1
!tstop=5
!stop=0
while !stop=0
e1.ls y c xs

!mint=10000
!removedvar=0
for !i=1 to xs.@count
   !currentt = @abs(e1.@tstats(!i+1))    'note plus one is since the equation has a constant as the first variable, but we are not testing the constant
   if !currentt < !mint then
      !mint = !currentt
      !removedvar=!i
   endif
next

if !mint>!tstop then
   !stop=1
else
   if !removedvar>0 then
      %removedvarname=xs.@seriesname(!removedvar)
      xs.drop {%removedvarname}
   endif
endif
wend

show e1


'run an automatic stepwise and see if it matches
equation e2.stepls(METHOD=UNI,BTOL=5,BACK,TSTAT) y c @ g
show e2


Re: Manual backwards stepwise routine

Posted: Mon Nov 03, 2014 9:28 am
by lilian.ferro
Is it possible to include ARMA terms in this routine? I've tried to adapt your code, but it is not working.

Here is what I've tried to do:
group xs
xs.add ar(1) ma(1)

Tank you very much!

Re: Manual backwards stepwise routine

Posted: Mon Nov 03, 2014 9:36 am
by EViews Gareth
You can't add AR or MA terms to a group, so, no, this method will not work at all.