Hi All,
I have data that resembles the following:
In the above dataset, I have regressand y, regressor x, and data by year, for 2 distinct income categories ( high vs low, WLOG). I wish to run multiple regressions- I ideally want to run regressions by income group*year. So in the above, that would correspond to 4 regressions (income=1, year =1979), (income=2, year=1980) etc.
One easy to to do this would be to combine the group(.) option by the egen command, and then use the by command over different values of that grouping variable. What I do wish to do in fact, is to store the beta coefficients in a nice 2*2 matrix (in this case) , with the coefficients conveniently stored in cells that represent specific year-income combinations. Is there an elegant way to do this? I can probably do this by brute force, but if there was a convenient way of doing so, it would save me quite some time.
Many thanks,
C
I have data that resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(year y x income) 1979 324 324 1 1979 324 324 2 1979 43 324 1 1979 324 234 2 1980 432 324 1 1980 2 324 2 1980 324 324 1 1980 324 234 2 end
In the above dataset, I have regressand y, regressor x, and data by year, for 2 distinct income categories ( high vs low, WLOG). I wish to run multiple regressions- I ideally want to run regressions by income group*year. So in the above, that would correspond to 4 regressions (income=1, year =1979), (income=2, year=1980) etc.
One easy to to do this would be to combine the group(.) option by the egen command, and then use the by command over different values of that grouping variable. What I do wish to do in fact, is to store the beta coefficients in a nice 2*2 matrix (in this case) , with the coefficients conveniently stored in cells that represent specific year-income combinations. Is there an elegant way to do this? I can probably do this by brute force, but if there was a convenient way of doing so, it would save me quite some time.
Many thanks,
C
Comment