Dear Colleagues,

I have faced with the problem that function rollaply with rolling window for
calculation of volatility doesn't give the all results of calculations.

I have run the rolling window for calculation in Excel and obtained that the
number of outputs for Excel is 36 and for R is 18. The total number of
observations is 37.  In the attachment you can find pdf of the Excel and
Excel file. Below you can find my commands in R.

> Ret<-read.csv("data.csv")
> Ret_1<-zoo((Ret))
> Ret_2<-rollapply(Ret_1,20,sd)
> Volatility_20<-sd(Ret_2)
> Volatility_20
      Data
0.03802453
> Ret_2
        Data
10 0.9170356
11 0.9147269
12 0.8982093
13 0.9169873
14 0.9156607
15 0.8961262
16 0.9615083
17 0.9804045
18 0.9853978
19 0.9888628
20 0.8798952
21 0.8408839
22 0.9429053
23 0.9498478
24 0.9464991
25 0.9305918
26 0.9408653
27 0.9434271
>

-- 
Best regards,

Andy

Attachment: R_error.pdf
Description: Adobe PDF document

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to