Hi!
I'm trying to run a regression and separating the results by a binary variable, this is easy to do it with the use of bysort. However, in the following steps I'm trying to construct a matrix with the values of each regression so first I need to store the results of the regression with a certain name. The problem is that when I use matrix list to see the stored results I only get the results of the last regression and not of both
sysuse auto.dta
bysort foreign: regress price mpg weight headroom
matrix list r(table)
To be a little more clear I want to achieve something like this, but preferably using a loop or something that can be replicated:
reg price mpg weight headroom if foreign == 0
matrix res1=r(table)
reg price mpg weight headroom if foreign == 1
matrix res2=r(table)
matrix list res1
matrix list res2
I'm trying to run a regression and separating the results by a binary variable, this is easy to do it with the use of bysort. However, in the following steps I'm trying to construct a matrix with the values of each regression so first I need to store the results of the regression with a certain name. The problem is that when I use matrix list to see the stored results I only get the results of the last regression and not of both
sysuse auto.dta
bysort foreign: regress price mpg weight headroom
matrix list r(table)
To be a little more clear I want to achieve something like this, but preferably using a loop or something that can be replicated:
reg price mpg weight headroom if foreign == 0
matrix res1=r(table)
reg price mpg weight headroom if foreign == 1
matrix res2=r(table)
matrix list res1
matrix list res2
Comment