MATLAB Program for Calculating Hurst Exponent

Resource Overview

This MATLAB implementation computes the Hurst exponent using the overlapping sub-intervals method with visualization capabilities for time series analysis.

Detailed Documentation

The following code provides a MATLAB function for calculating the Hurst exponent, which measures long-term memory in time series data and is commonly applied in financial market analysis. The implementation utilizes the overlapping sub-intervals method (R/S analysis) to compute the Hurst exponent and includes graphical visualization to assist in result interpretation. Key implementation details: - The algorithm partitions the time series into exponentially increasing sub-intervals - For each partition size, it calculates the rescaled range (R/S) statistic - A linear regression on log-log plot determines the Hurst exponent - The function generates diagnostic plots showing the relationship between R/S statistics and interval sizes Reference literature for additional information: [1] E. Peters, Fractal Market Analysis: Applying Chaos Theory to Investment and Economics, John Wiley & Sons, 1994. [2] R. N. Mantegna and H. E. Stanley, An Introduction to Econophysics: Correlations and Complexity in Finance, Cambridge University Press, 2000. MATLAB function implementation: function H = hurst(X) % Compute the Hurst exponent of time series X using R/S analysis % Input: X - time series data vector % Output: H - Hurst exponent value N = length(X); n = floor(log2(N)); % Determine maximum partition level based on data length S = zeros(n,1); % Preallocate array for R/S statistics % Calculate R/S statistic for different partition sizes for i = 1:n Si = 0; % Process overlapping sub-intervals for k = 0:2^(i-1)-1 index = k*2^(n-i)+1:(k+1)*2^(n-i)+1; Xk = X(index); zk = cumsum(Xk-mean(Xk)); % Cumulative deviation from mean Rk = max(zk)-min(zk); % Range calculation Si = Si + Rk; end S(i) = Si/(2^(i-1)); % Average R/S for current partition level end % Linear regression on log-log scale to determine Hurst exponent p = polyfit(log2((1:n)'),log2(S),1); H = p(1); % Slope represents Hurst exponent % Generate diagnostic plot plot(log2((1:n)'),log2(S),'o',log2((1:n)'),polyval(p,log2((1:n)')),'-'); xlabel('log2(n)') ylabel('log2(R/S)') end