# Is this the right way to compute "realized daily market return variance, annualized, over the preceding 126 trading days”?

Realized.Variance<-rollapply((log(Fama.French.daily$Mkt+1)^2) ,126,sum,by=1)  So Fama.French.dail$Mkt is my daily Market return.

To calculate the realized Variance over the preceding 126 days, i took the sum of the squared log returns of the past 126 observations. (Using the approach above the value on day 126 includes day 126, so its the preceding value for day 127.) Anyway, How can i annualize them ? Is it times 252 or do i just multiply by 2 since i already summed up half a year?

• Don’t follow your code, but in terms of annualised variance, you will need to multiply the variance by 252 as the variance you computed represents the variance of daily returns. Had you computed the return over half a year, $X_{127}-X_{1}$, then you could have annualised by multiplying it by 2. Jun 30, 2019 at 19:46
• And re variance pls see discussion here: stackoverflow.com/questions/13195442/moving-variance-in-r Jun 30, 2019 at 19:51