Hello,

I am attempting to return coefficient results from multiple regressions using a simulation. Below is an example of a basic code. Note the simulation will only return results from the last regression ran and not the first. How can I return results from both regressions?

Important Note: This is simple to do with return scalar method for each coefficient (ie return scalar beta1 = _b[x1]), but I interested in some kind of command because I am going to have the number of regressors be variable. For example, I want the user to simply be able to say, I want ten regressors, and my simulation spits out 10 coefficient estimates for 2 regressions for 100 simulations. This is all without having the user to type the return function 10 times in the lines after each regression command line, and then also having to type beta1=r(beta1) for 20 different betas in the simiulation command line.

I have been stuck on this for a while so please be very clear with any response. Thank you!



clear

program drop beta
program beta, rclass

clear
set obs 100
gen x1 = rnormal(0,3)
gen x2 = rnormal(0,4)
gen x3 = rnormal(0,4)
gen y= rnormal(0,1)
reg y x1 x2

gen new_y = rnormal(0,3)
reg new_y x1 x3

end

simulate _b, reps(100): beta