TL;DR
The dCovTS R package provides a comprehensive toolkit for detecting nonlinear dependencies in univariate and multivariate time series using distance covariance and correlation. By moving beyond traditional linear measures, it allows researchers to identify complex temporal relationships that standard autocorrelation functions often miss.
The Challenge of Nonlinearity in Time Series
Traditional time series analysis relies heavily on the Autocorrelation Function (ACF), which is based on Pearson’s correlation. While effective for linear relationships, Pearson’s correlation can fail to detect dependencies where the relationship is nonlinear or where the variables are dependent but uncorrelated (e.g., $Y = X^2$ where $X$ is symmetric around zero).
In many fields—such as finance, meteorology, and signal processing—data often exhibits "hidden" dependencies. The dCovTS package addresses this gap by implementing Distance Covariance (dCov) and Distance Correlation (dCor). These metrics have a powerful property: they are equal to zero if and only if the variables are truly independent, regardless of whether the relationship is linear or nonlinear. This makes them significantly more robust than traditional linear metrics for exploratory data analysis.
Methodology and Implementation
The package implements the "auto-distance" versions of these metrics, measuring the dependence between a time series $X_t$ and its lagged version $X_{t+j}$.
Key features of the implementation include:
- Estimators: It provides both biased estimators (based on V-statistics) and unbiased estimators (utilizing U-centered matrices). Unbiased estimators are particularly valuable for avoiding the systematic underestimation of correlation in smaller datasets, a common issue in time series analysis.
- Multivariate Analysis: It extends these concepts to multivariate series, computing an "auto-distance correlation matrix" that captures dependencies across multiple variables over time.
- Smoothing Kernels: For formal hypothesis testing of pairwise independence, the package includes several kernel functions (Bartlett, Daniell, Parzen, etc.) to smooth the generalized spectral density, ensuring consistent testing across different data structures.
Statistical Inference and Resampling
Because the null distribution of distance-based statistics is complex (technically, they are degenerate V-statistics), the package uses three bootstrap-based methods to calculate confidence intervals and p-values:
- Wild Bootstrap: Specifically designed to maintain the dependent structure of the time series data during resampling.
- Subsampling: Calculates critical values for each lag separately, allowing for more granular inference.
- Independent Bootstrap: A standard resampling approach for cases where independence is the baseline assumption.
Practical Application and Results
The core advantage of dCovTS is the ability to see structure in data that looks like white noise under a standard ACF plot. If the Auto-Distance Correlation Function (ADCF) shows significant peaks where ACF shows none, a nonlinear dependency is confirmed.
The package includes two real-world datasets to demonstrate its utility:
ibmSp500: Monthly returns for IBM stock and the S&P 500 index from 1926 to 2011. This is a classic example for exploring lead-lag relationships and nonlinear dependencies in financial markets.MortTempPart: A dataset containing daily cardiovascular mortality, temperature, and pollutant particulate matter in Los Angeles County (1970–1979), often used to study environmental impacts on health.
Functions like ADCFplot and mADCFplot generate intuitive visualizations of dependence across lags, complete with bootstrap-derived confidence thresholds. Furthermore, the UnivTest and mADCFtest functions provide rigorous p-values for the null hypothesis of independence, allowing for objective statistical conclusions.
Conclusion and Limitations
While dCovTS is a powerful tool, users should be aware of its computational intensity. Despite the use of optimized libraries like Rfast, distance correlation remains significantly slower than the Fast Fourier Transform (FFT) methods used for linear ACF. Very high-frequency or extremely long datasets may still pose a challenge. Additionally, while the package identifies that a dependency exists, it does not specify the mathematical form of that dependency, requiring further exploratory analysis to model the relationship fully.
Summary updated