Dear Statalist users,
I would like to run a regression by different groups (roughly 1000), saving regression coefficients and number of observations in a new variable, such that for each individual observation in the group I have a variable showing the respective regression coefficient that the regression for that group yielded.
I have had a look at combining by, sort and regress:
and, alternatively, statsby
but was not able to find out how to store the coefficient values in a new variable.
How can I do it? And, what is the most convenient way of doing this? Do you have any other suggestions?
Many thanks,
Milan
I would like to run a regression by different groups (roughly 1000), saving regression coefficients and number of observations in a new variable, such that for each individual observation in the group I have a variable showing the respective regression coefficient that the regression for that group yielded.
I have had a look at combining by, sort and regress:
Code:
sort group by group: regress y x
Code:
statsby _b, by(group): regress y x
How can I do it? And, what is the most convenient way of doing this? Do you have any other suggestions?
Many thanks,
Milan
Comment