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
Bootstrap in MontecarloI am running some issues on how to run a boostrap in a montecarlo. I need to generate 50 observation…
Can I upload my dataset on this website?I have a very tough question. And the data set is tons of observations and tons of time periods. So …
How to store each estimate of multiple regressions in a loop commandHi, I am running regression commands similar to the followings: logit y cov1 cov2 cov3 cov4 cov…
quantile for dynamic panelHi Do anyone read the paper of Galvao (2011) about quantile regression for dynamic panel data with f…
Convergence not achieved in technical efficiency modelHi All, When I am running my frontier model (panel data) I got the message called "convergence not …
Subscribe to:
Post Comments (Atom)
0 Response to Saving regression results
Post a Comment