Manual backwards stepwise routine

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11262
Joined: Tue Sep 16, 2008 5:38 pm

Manual backwards stepwise routine

Postby EViews Gareth » Fri Jan 23, 2009 9:19 am

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

Follow us on Twitter @IHSEViews

lilian.ferro
Posts: 5
Joined: Mon Nov 03, 2014 9:22 am

Re: Manual backwards stepwise routine

Postby lilian.ferro » Mon Nov 03, 2014 9:28 am

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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11262
Joined: Tue Sep 16, 2008 5:38 pm

Re: Manual backwards stepwise routine

Postby EViews Gareth » Mon Nov 03, 2014 9:36 am

You can't add AR or MA terms to a group, so, no, this method will not work at all.
Follow us on Twitter @IHSEViews


Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 1 guest