Hello everybody,
I am new in this forum and I hope that I will get some advice from you.
I would like to run 255 regression models having one dependent variable and 9 independent variables. I would like to model every possible combination of the independent variables by including max 4 independent variables in one model specification.
The following code works fine, but how do I store the results in a new dataset?
[CODE] tuples x1 x2 x3 x4 x5 x6 x7 x8 x9, max(4) dis forval i = 1/255 { reg y `tuple`i'' }
[/CODE] I would like to generate a new dataset in with 255 observations (each model specifications is one observation) and the variables are: beta_x1; se_x1; tvalue_x1; beta_x2; se_x3; tvalue_x3 up to beta_x9; se_x9; tvalue_x9 and r2 and const for each obversvation. If the variable is not part of the model secification a missing value should occur.
I have tried this code but the result is a new dataset with 255 observations where only the first coefficient of the given model specification is displayed.
[CODE] postfile test N beta beta_se const const_se str20 id using "results.dta", replace tuples x1 x2 x3 x4 x5 x6 x7 x8 x9, max(4) dis forval i = 1/255 { reg y `tuple`i'' mat results = r(table) local N = e(N) local beta = results[1,1] local beta_se = results[2,1] local const = results[1,2] local const_se = results[2,2] post test (`N') (`beta') (`beta_se') (`const') (`const_se') ("id`i'") } postclose test preserve use results.dta, clear [/CODE] Any thoughts or suggestions are greatly appreciated! Thank you
Related Posts with Store regression results of a loop in a new dataset
Multinomial logit/probit models with binary endogenous explanatory variableHi all, I would like to estimate the following equation: Y = b0 + b1T + X*beta + U1 (1) where T is…
Cross-fold validation in two part models (health economics example)Dear statalisters, I am currently trying to develop a mapping algorithm from the EQ-5D-5L to a dise…
Hybrid long-wide. Help with transforming datasetHi, I recently got a dataset of 600 patients admitted to the ICU. It contains info regarding sex, a…
melogit Confidence Interval missing?Hi all, I'm running a multilevel mixed-effects logistic regression, with random intercepts per my c…
Overlay graphs, without the twoway commandDear all, I am trying to overlap this two graphs: Code: twoway (qfit HH_SLMPcom BSL_GDT) dotplot …
Subscribe to:
Post Comments (Atom)
0 Response to Store regression results of a loop in a new dataset
Post a Comment