Hi there,
I used the rolling regression with window 12 months to calculate expected Beta and then I calculate expected returns. After that, I calculate abnormal returns = Real returns - Expected returns.
My codes is as the following:

asreg excessR MarpreCSI SmB HmL MOM , wind( Month 12)

gen expectedALPHA4= Riskfreerate3monthdeposit + _b_MarpreCSI * MarpreCSI +_b_SmB * SmB + _b_HmL * HmL +_b_MOM * MOM

gen ALPHA4= rp- expectedALPHA4

and I also calulate the residuals as:

gen resid4= excessR - _b_cons - _b_MarpreCSI * MarpreCSI - _b_SmB * SmB - _b_HmL * HmL - _b_MOM * MOM

So, I wonder my code is correct or not?

Thank you in advance!