Hello everybody!
I have a panel dataset consisting of daily data with around 10000 companies and I want to perform regressions while obtaining the standard deviation of the residuals for each regression performed.
My regression formula looks like this:
I have declared a panel dataset and want to restrict my regression sample to one of the companies (permno) and one month for every single regression (month). In a last step I want to store the residual standard deviation in a seperate variable in my panel for every regression sample performed.
First:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable"
Second:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 2nd cell
...
A similar thread considered the following code:
https://www.statalist.org/forums/for...ing-regression
With the code stated above I cannot run the regressions. Do you have any considerations on my code or on a faster way for computing the standard deviation of regression residuals?
Thank you in advance!
Nils
I have a panel dataset consisting of daily data with around 10000 companies and I want to perform regressions while obtaining the standard deviation of the residuals for each regression performed.
My regression formula looks like this:
Code:
regress ret MktRF SMB HML
First:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable"
Second:
Reg Y X
Calculate residuals
Compute Standard Deviation of residuals
Store result in "new variable" 2nd cell
...
A similar thread considered the following code:
https://www.statalist.org/forums/for...ing-regression
Code:
capture program drop my_regress program define my_regress, rclass syntax varlist [if] regress `varlist' `if' tempvar resid predict `resid' if e(sample), resid summ `resid' return scalar sdr = r(sd) exit end rolling sd_resid = r(sdr) reg_id, w(15): my_regress ret MktRF SMB HML
Thank you in advance!
Nils
Comment