I want to run regressions using one variable at a time and store results for each of those. The following code does exactly that.
sysuse auto
local var mpg rep78 headroom trunk weight
estimates clear
foreach v of varlist `var' {
regress price `v'
estimates store m_`v'
}
esttab m_*
However, instead of saving the results with variable names (m_'v') I wanted to use a numeric identifier for the results (e.g., m_1, m_2). When I use the following code I am getting extra models for the first variable in the list (mpg).
sysuse auto
local var mpg rep78 headroom trunk weight
estimates clear
local n : word count `var'
forvalues i = 1/`n' {
foreach v of varlist `var'{
regress price `v'
estimates store m_`i'
local ++i
}
}
esttab m_*
So, instead of getting only five outputs I am now getting nine outputs. 'n' is five, and for the first variable 'mpg' I am getting five outputs. I am surely doing something pretty silly. Any suggestions?
Thank you for your help.
Sincerely,
Manish
related posts
https://www.statalist.org/forums/for...un-regressions
https://www.statalist.org/forums/for...oop-regression
Related Posts with Saving regression results
margins plot interpretation for continuous variablesHi there, I have just done a plot of my margins for how the effect of savings rate on investment ra…
Differential Item Functioning (DIF) with irt grmHello all, I have scoured the internet for answers, and downloaded several packages in Stata to no …
rollregHi. I'm using rollreg. There are a number of important (mutually exclusive) parameters to set: move…
Fixing the x-axis range for combined (scatter and line) graphsDear All, When I plot the below graphs, I am not able to arrange the x axis range. I want it to be m…
estpost ttest with multiple conditions and columnsDear Statalist Community, I'm looking to make a summary statistics table for some of my key variabl…
Subscribe to:
Post Comments (Atom)
0 Response to Saving regression results
Post a Comment