## 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: 11926
Joined: Tue Sep 16, 2008 5:38 pm

### Manual backwards stepwise routine

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 XScreate u 1000rndseed 1group xsgroup gfor !i=1 to 20   series x!i=nrnd   %name="x"+@str(!i)   xs.add {%name}   g.add {%name}nextseries y = nrnd + 3for !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=0while !stop=0e1.ls y c xs!mint=10000!removedvar=0for !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   endifnextif !mint>!tstop then    !stop=1else    if !removedvar>0 then      %removedvarname=xs.@seriesname(!removedvar)      xs.drop {%removedvarname}   endifendifwendshow e1'run an automatic stepwise and see if it matchesequation e2.stepls(METHOD=UNI,BTOL=5,BACK,TSTAT) y c @ gshow e2`

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

### Re: Manual backwards stepwise routine

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

Tank you very much!

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

### Re: Manual backwards stepwise routine

You can't add AR or MA terms to a group, so, no, this method will not work at all.

### Who is online

Users browsing this forum: No registered users and 1 guest