Hello everyone,

I am currently trying to implement the Shanken (1992) Correction for my dataset after running asreg ,fmb.

I somehow fail to obtain the standard errors of the residuals - is there any comand or way to obtain these?

My dataset is structured the following way (using random numbers, simplified):
Key ID u CAP CPI GDP
1001 1 -.1154 .0025 .0084 -.0032
1002 2 -.1154 .0025 .0084 -.0032
.. .. .. .. .. ..
1267012 12 .0232 -.302 .0122 .0032
ID is basically the number of the month of the given year.

I am running this loop to estimate the returns of the next 12 months (column u) using the identical betas for CAP, CPI & GDP I predicted in my stage 1 regression for each month of the given year.

scalar COUNTER = 12
scalar COUNTER2 = 0

//Using a counter from 1 to 8, since I am performing the regression for a period of 8 years
forval i = 1/8 {

use "C:\Stata_Data\Stage2.dta", clear

drop if ID > COUNTER
drop if ID <= COUNTER2

asreg u CAP CPI GDP, fmb
matrix b = e(b)
scalar A = el(b,1,1)
scalar B = el(b,1,2)
scalar C = el(b,1,3)

use "C:\Stata_Data\FMB.dta", clear
replace b_b_REX = A if ID ==`i'
replace b_b_CPI = B if ID ==`i'
replace b_b_TS = C if ID ==`i'
save "C:\Stata_Data\FMB.dta", replace

scalar COUNTER = COUNTER +12
scalar COUNTER2 = COUNTER2 +12
}
In a next step, as already mentioned, I would like to include the Shanken Correction. Since I haven't found any code or tool which can help me calculating the Shanken Correction, I am currently working on my own way to make it work. Thus, I need to obtain the standard errors of the residuals. Can anyone help me out here?

If anyone has a working solution for the Shanken Correction, I would highly appreciate some further help.

Best regards and thank you in advance,

Tobias