I am pretty new to R and I have been trying to compute a rolling Hurst exponent with no avail. I have installed packages fArma (for the Hurst) and zoo (for the rollapply). The data is in a dataframe called 'data' and is variable 'returns'. The following code for the Hurst works great;
rsFit(data$returns, levels = 50, minnpts = 3, cut.off = 10^c(0.7, 2.5), + doplot = FALSE, trace = FALSE, title = NULL, description = NULL)
Below is my attempt at a rolling Hurst exponent of window size 230, which generates an error.
rollapply(data$returns, 230, (rsFit(data$returns, levels = 50, minnpts = 3, cut.off = 10^c(0.7, 2.5), + doplot = FALSE, trace = FALSE, title = NULL, description = NULL)))
Any help with the code would be much appreciated. I am trying to calculate the Hurst exponent over a 230 period window, that rolls forward 1 period at a time.
The data is;
returns
1 -0.002002003
2 -0.002006019
3 0.000000000
4 0.000000000
5 -0.009077218
6 -0.003044142
7 -0.002034589
8 0.004065046
9 0.002026343
10 0.001011634
11 0.001010612
12 0.000000000
13 -0.001010612
14 -0.001011634
15 0.003031837
16 -0.001009591
17 0.001009591
18 -0.002020203