Hi All,
I have a dataset that looks like:
Here, I have information on individuals, identified by ID, on a regressand y and regressor x. I wish to run separate regressions of y on x for each individual, and compute residuals for each individual separately. (Note that this is different from running a regression of y on x, and computing residuals, as I am allowing for different slopes for each individual, which will affect residuals.
I tried:
This will simply run all the regressions, but of course does not store estimates in order to use the predict command afterwards. Any tips on this will be most useful.
CS
I have a dataset that looks like:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(ID y x) 1 23 2 1 2 3 1 2 1 1 3 2 1 2 22 2 2 1 2 2 2 2 2 3 2 123 1 2 3 . end
Here, I have information on individuals, identified by ID, on a regressand y and regressor x. I wish to run separate regressions of y on x for each individual, and compute residuals for each individual separately. (Note that this is different from running a regression of y on x, and computing residuals, as I am allowing for different slopes for each individual, which will affect residuals.
I tried:
Code:
by id: regress y x
CS
Comment