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
0 Response to Store regression results of a loop in a new dataset
Post a Comment