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
META-ANALYSIS without standard-deviationsI am trying to perform a meta-analysis estimation with data from studies using different methodologi…
How to do two part model when there is one independent variable is binary and endogenous?I want to use the two-part model to estimate food expenditure (Y), in the Xs, one variable is endoge…
regexmHi STATALIS I want to select patients with "IAM" in the studydescription_all variable . The "studyd…
How to store multiple regression resultsHello, I am currently running a Vector autoregression with 5 lags and 4 exogenous variables. I have …
How to sample with unequal probability in a given populationHi Statalist experts, Suppose I have data on a population of N subjects, each has X1-X5 and and var…
Subscribe to:
Post Comments (Atom)
0 Response to Store regression results of a loop in a new dataset
Post a Comment