I need to select subsets from a variable list and run regressions on it.
my variable set is x1 x2 x3..... x10
first i select all variables without x1 and run the regression
in the next iteration i select all variables without x1 and run the regression.
Also im keeping position in which the minimum SE occured.
I wrote the following code.
But an error occurs when i try to increase the number of variables. It works perfectly upto 9 variables. But gives an error "NA found in matrix in".
i have marked the location as 'ERROR HAPPENS HERE" in the code.
Any guidance would be highly appreciated.
Code: Select all
group t_group x1 x2 x3 x4 x5 x6 x7 x8 x9
scalar position=0
!loop_count= 1
for %y 1 2 3 4 5 6 7 8 9
group t_
for !j=1 to t_group.@count
if !j<>{%y} then
t_.add t_group(!j)
endif
next
equation eq{%y}.ls Y c t_
eq{%y}.makeresid res_ids{%y} 'creating residuals
coef max_er
if {%y}=1 then
max_er=eq{%y}.@se
position=!loop_count
else
if max_er>eq{%y}.@se then 'ERROR HAPPENS HERE
max_er=eq{%y}.@se
position=!loop_count
endif
endif
next
