Hello all!

I've got a panel data with variables: firmid, year, and rdexpenditure.

I want to get the standard deviation of the residuals from the R&D expenditure trend of the firm over the past 5 years. I was considering using asreg. The command is:

asreg rdexpenditure year, window(year 5) by(firmid) fitted

But only 3 residuals returned for each firm over 5 years. Is it oorrect to compute the standard deviation with only 3 residuals? If not, is there any comand I can use to get all the 5 residuals properly?

Thank you for your help!