Hello All,
I am writing because I have hit a bit of a problem that I cannot seem to figure out. I am using stepwise regression. I do understand the perils of stepwise regression, but I have my reasons for using it. Here is the issue that I am having. I need to be able to grab the names of the variables left in the stepwise regression. I can grab the coefficients from the matrix e(b) or the r(table), but I can't seem to grab the names of the variables. Once I grab the names, I want to be able to put those names into a local macro to use for other analyses. How do I do this so the 3 significant variable names are extracted and put into a local macro to be used in other analyses? Here is my sample code, note I did use dataex to generate the code listed below:
clear
sysuse auto
generate weight2 = weight^2
stepwise, pe(.05): regress mpg weight weight2 displ gear turn headroom foreign price
ereturn list
return list
matrix var = e(b)
matrix list var
matrix table = r(table)
matrix list table
Any assistance with this will be helpful. What are some methods of grabbing the variable names of the 3 significant variables, and putting the names of the 3 variables into a local macro so that it could be used in other analyses? Thank you in advance
I am writing because I have hit a bit of a problem that I cannot seem to figure out. I am using stepwise regression. I do understand the perils of stepwise regression, but I have my reasons for using it. Here is the issue that I am having. I need to be able to grab the names of the variables left in the stepwise regression. I can grab the coefficients from the matrix e(b) or the r(table), but I can't seem to grab the names of the variables. Once I grab the names, I want to be able to put those names into a local macro to use for other analyses. How do I do this so the 3 significant variable names are extracted and put into a local macro to be used in other analyses? Here is my sample code, note I did use dataex to generate the code listed below:
clear
sysuse auto
generate weight2 = weight^2
stepwise, pe(.05): regress mpg weight weight2 displ gear turn headroom foreign price
ereturn list
return list
matrix var = e(b)
matrix list var
matrix table = r(table)
matrix list table
Any assistance with this will be helpful. What are some methods of grabbing the variable names of the 3 significant variables, and putting the names of the 3 variables into a local macro so that it could be used in other analyses? Thank you in advance
Comment