calc_hurst: Calculate the Hurst exponent from the volatility ratio of...

View source: R/RcppExports.R

calc_hurstR Documentation

Calculate the Hurst exponent from the volatility ratio of aggregated returns.

Description

Calculate the Hurst exponent from the volatility ratio of aggregated returns.

Usage

calc_hurst(tseries, aggv)

Arguments

tseries

A time series or a matrix of log prices.

aggv

A vector of aggregation intervals.

Details

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.

Value

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.

Examples

## 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)


algoquant/HighFreq documentation built on Feb. 9, 2024, 8:15 p.m.