[R] Error in Rolling window of function - rollapply

Andriy Fetsun fetsun at googlemail.com
Tue Jul 7 21:38:56 CEST 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: R_error.pdf
Type: application/pdf
Size: 2476 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090707/9ff0a558/attachment-0002.pdf>


More information about the R-help mailing list