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
Problem with multigroup SEMHello, I'd like to know what is the code for estimating the indirect effects in multigroup SEM. Fo…
Time trend in xtunitroot ht testHi everyone, I run the Harris-Tzavalis unit-root test with time trend as follows: xtunitroot ht in…
Lambert functionHi everyone, I would need to compute the Lambert function W(a) in Stata, but I cannot find a command…
Dunn Test Median Comparison Error ?I might be doing this wrong but I named my groups numbers, so "7", "8" and "9" are separate groups. …
Dunn Test Bonferroni Correction gives p-value of 1. Error?I did the Dunn test using the following code: Code: dunntest rating, by(outcome) ma(bonferroni) I …
Subscribe to:
Post Comments (Atom)
0 Response to Saving regression results
Post a Comment