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
likelihood ratio testsAm i correct in thinking that likelihood‐ratio tests can be used to assess whether extra variables j…
Difference in Differences with Multiple Periods - Interpretation of CoefficientI am currently looking at the effect of a policy change on some states in the US that implemented th…
Fixed effect and reverse causalityHi Statalist, i am analyzing a dataset of performance for Footballplayers and How a transfer affect…
Computation of densities for exemplary observations with Finite Mixture Model (FMM) and Quantil Regression (QR)Dear Statalist, I want to use a Finite Mixture Model (4 Gaussian's) and a Quantile Regression to co…
SARAR model: interpretationDear All, I estimate a model like the following spatial model (SARAR): y=rho*Wy+beta*X+u u=psi*u+e…
Subscribe to:
Post Comments (Atom)
0 Response to Saving regression results
Post a Comment