calc_hurst | R Documentation |
Calculate the Hurst exponent from the volatility ratio of aggregated returns.
calc_hurst(tseries, aggv)
tseries |
A time series or a matrix of log prices. |
aggv |
A vector of aggregation intervals. |
The function calc_hurst()
calculates the Hurst exponent from the
ratios of the volatilities of aggregated returns.
An aggregation interval is equal to the number of time periods between the neighboring aggregation end points.
The aggregated volatility \sigma_t
increases with the length of the
aggregation interval \Delta t
.
The aggregated volatility increases as the length of the aggregation
interval \Delta t
raised to the power of the Hurst exponent
H
:
\sigma_t = \sigma {\Delta t}^H
Where \sigma
is the daily return volatility.
For a single aggregation interval \Delta t
, the Hurst
exponent H
is equal to the logarithm of the ratio of the
volatilities divided by the logarithm of the aggregation interval
\Delta t
:
H = \frac{\log{\sigma_t} - \log{\sigma}}{\log{\Delta t}}
For a vector of aggregation intervals \Delta t_i
, the
Hurst exponent H
is equal to the regression slope between the
logarithms of the aggregated volatilities \sigma_i
versus the
logarithms of the aggregation intervals \Delta t_i
:
H = \frac{\code{cov}(\log{\sigma_i}, \log{\Delta t_i})}{\code{var}(\log{\Delta t_i})}
The function calc_hurst()
calls the function calc_var_ag()
to calculate the variance of aggregated returns \sigma^2_t
.
The Hurst exponent calculated from the volatility ratio of
aggregated returns. If tseries
contains multiple columns, then the
function calc_hurst()
returns a single-row matrix of Hurst
exponents.
## Not run:
# Calculate the log prices
closep <- na.omit(rutils::etfenv$prices[, c("XLP", "VTI")])
closep <- log(closep)
# Calculate the Hurst exponents for a 21 day aggregation interval
HighFreq::calc_hurst(prices, aggv=21)
# Calculate the Hurst exponents for a vector of aggregation intervals
aggv <- seq.int(from=3, to=35, length.out=9)^2
HighFreq::calc_hurst(prices, aggv=aggv)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.