Stepwise elimination in system

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

sean123
Posts: 34
Joined: Wed Apr 25, 2012 11:53 am

Stepwise elimination in system

Postby sean123 » Wed Apr 25, 2012 12:04 pm

Hi,

I'm currently working on creating a program which essentially will provide me with a way of doing a stepwise elimination of insignificant variables in a system of equations. This system of equations is in turn generated from a VAR model, so what I want in the end is a restricted VAR. The problem I have is how to code the actual elimination part. I found a great code for stepwise regression in a guide on this board and implemented it in my analysis, but I can't seem to figure this bit out. The code looks like this:

Code: Select all

'lag for endogenous variables !i = 4 'lag for exogenous variables !j = 3 'define the t-value cut-off point (absolute value) !tstop=1.6449 !stop=0 'estimate VAR(!i,!j) var var_e.ls 1 !i dr ldkpi tbill @ c usatbill(-1 to -!j) 'make a system of the estimated VAR var_e.makesystem(n=sys_e) 'estimate system sys_e.ls 'create a variable to store the smallest t-value in !mint=10000 'create a variable to store the id of the variable showing the smallest t-value !removedvar=0 'create a while condition while !stop=0 'create loop from C(1) to C(LAST) for !i=1 to sys_e.@ncoefs !currentt = @abs(sys_e.@tstats(!i)) '!currentt is the absolute value of the t-statistic for coefficient i if !currentt < !mint then !mint = !currentt !removedvar=!i endif 'if the absolute t-value for coefficient i is smaller than the current smallest t-value the coefficient id is stored in !removedvar next if !mint>!tstop then 'when the smallest t-value is larger than the cut-off point this assigns 1 to !stop, which will terminate the while loop !stop=1 else sys_e.@coefs(!removedvar)=0 '!removedvar is equal to the coefficient, which currently has the lowest t-value and this statement should drop it from the system equation endif wend
Any help would be much appreciated (the part I need help with is after the last 'else' condition). As it stands now it sets all coefficients to 0, but the intention of this specification is that the current !removedvar should be set to 0 and thus have no impact in the system. Much better would be if there was a way to delete it altogether with its corresponding variable (maybe this is the way, given a correct specification?). I would also like to exclude the intercepts from this elimination process, but I think I'll be able to figure it out by myself.

Thanks in advance!

Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest