getting variable names from stepwise regression
Posted: Thu Feb 13, 2014 1:46 pm
Hey,
I am using eviews 7 for my master thesis to try and find a way to forecast exchange rates using a variety of factors. I do this by using rolling regressions on one variable at a time by means of a For loop with a rolling window that moves forward one month at a time. I then forecast the future exchange rate each month by calculating C(0) + C(1) * most recent variable value (as part of the loop, so it's automated as well), which gives me a time series with predictions for each month once the program has finished running. So far so good. Next, I try to improve on the result by using backwards stepwise regression to automatically select a combination of significant variables each month instead of choosing one variable at a time and checking for significance manually. The problem is that by getting the program to select the significant variables in this way, I don't know which variables are actually used each month, so I can't refer back to these variables within the For loop. I need a function that returns the variables used in each equation of the rolling regression so I can use them in the above formula to make predictions. However, @varlist only returns a string, which doesn't help me any. On the other hand, if I write something like "genr C2_stepwise{%S}{%N}(23) = eq{!J}.c(1)", then I have the first factor coefficient, but I still don't know which variable value I should multiply the coefficient with since I don't know which variables were selected.
Can anyone tell me if there is a good way to do this? Or do I have to scratch the whole idea? Below is the code for my stepwise rolling regression, if that helps.
And the original (regular LS) program, just in case:
Any help is appreciated!
I am using eviews 7 for my master thesis to try and find a way to forecast exchange rates using a variety of factors. I do this by using rolling regressions on one variable at a time by means of a For loop with a rolling window that moves forward one month at a time. I then forecast the future exchange rate each month by calculating C(0) + C(1) * most recent variable value (as part of the loop, so it's automated as well), which gives me a time series with predictions for each month once the program has finished running. So far so good. Next, I try to improve on the result by using backwards stepwise regression to automatically select a combination of significant variables each month instead of choosing one variable at a time and checking for significance manually. The problem is that by getting the program to select the significant variables in this way, I don't know which variables are actually used each month, so I can't refer back to these variables within the For loop. I need a function that returns the variables used in each equation of the rolling regression so I can use them in the above formula to make predictions. However, @varlist only returns a string, which doesn't help me any. On the other hand, if I write something like "genr C2_stepwise{%S}{%N}(23) = eq{!J}.c(1)", then I have the first factor coefficient, but I still don't know which variable value I should multiply the coefficient with since I don't know which variables were selected.
Can anyone tell me if there is a good way to do this? Or do I have to scratch the whole idea? Below is the code for my stepwise rolling regression, if that helps.
Code: Select all
for %N _1m _3m _12m
for %S _eur _jap _uk
FOR !J = 1 to 145
smpl 1995M11+!J 1997M10+!J
equation eq{!J}.stepls(back,COV=HAC) exp{%S}{%N} @ c int_dif{%S}{%N} m_dif{%S} m_dif2{%S}{%N} tb_gdp{%S} tb_gdp_us cpi_dif{%S}
genr varlist{%S}{%N} = eq{!J}.@varlist
delete eq{!J}
next
next
nextCode: Select all
%M = "_uip"
%Y = "exchange_dif"
%X = "int_dif" (I change the variable each time I run the program)
for %N 1 3 12
for %S _eur _jap _uk
FOR !J = 1 to 145
smpl 1995M11+!J 1997M10+!J
equation eq{!J}.ls(COV=HAC) {%Y}{%S}_{%N}m c {%X}{%S}_{%N}m
genr forecast{%M}{%S}_{%N}m(22+!J) = eq{!J}.c(1) + eq{!J}.c(2) * {%X}{%S}_{%N}m(22+!J+{%N})
delete eq{!J}
next
next
next