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
Bootstrapping with 2 samplesHi there, I'm not an expert STATA user, so I hope to get some help in this forum. Here is my set up…
help with t tests and summary statisticsI suspect I am asking something quite simple, however after reviewing the ttest help file I am still…
Publishable tables of regression results beside originals entered by handDear Readers I want to produce quite a number of tables which compare original regression results i…
Model fit stattitics for GSEMHello, I am using Stata 15.1 to run gsem to test a panel data mediational model. I want to know wha…
Unable to load Excel file. Error: element not found.Hi everyone! I am trying to import an excel file from a shared folder on Dropbox into Stata and I g…
Subscribe to:
Post Comments (Atom)
0 Response to Store regression results of a loop in a new dataset
Post a Comment