BDSTest#
- class cultivars.diagnostics.nonlinearity.BDSTest(*, statistic, pvalue, dimension, epsilon, nobs, companions=())[source]
Bases:
_HypothesisTestVerdict of the BDS test of independence at one embedding dimension.
The correlation integral \(C_m(\varepsilon)\) is the fraction of pairs of \(m\)-histories \((y_t, \ldots, y_{t + m - 1})\) lying within \(\varepsilon\) of each other in the sup norm. Under independence the histories are close exactly when every coordinate is, so \(C_m(\varepsilon) = C_1(\varepsilon)^m\), and the standardized gap
\[W_m = \sqrt{T}\, \frac{C_m(\varepsilon) - C_1(\varepsilon)^m}{\hat\sigma_m(\varepsilon)} \;\xrightarrow{d}\; \mathcal{N}(0, 1)\]is the statistic (Brock, Dechert, Scheinkman & LeBaron 1996), with \(\hat\sigma_m\) the closed-form asymptotic standard deviation. The record is the statistic at the largest dimension asked for, with the lower dimensions as
companions. A dependence that shows at every dimension is the usual signature of neglected conditional heteroskedasticity; one that appears only at high dimension is rarer and worth a look. The asymptotic normal reference is reliable from about 500 observations and over-rejects below that, roughly 8% at nominal 5% on 250 Gaussian observations and 15% on 100, which the record says.- Variables:
statistic – The standardized statistic
W_m.pvalue – Its two-sided standard normal p-value.
dimension – The embedding dimension
m.epsilon – The radius, in the units of the series.
nobs – Observations.
companions – The lower dimensions
2 .. m - 1.
Note
The test is against any departure from i.i.d., so on raw data it rejects for linear autocorrelation as readily as for a threshold, and on residuals it rejects for an ARCH effect as readily as for a missed regime. It earns its place after the linear and ARCH structure has been removed, as the check that nothing is left. The summary lists the dimensions in ascending order, this record last.
See also
bds()– the producer.LinearityTest– the tests that name a specific nonlinear alternative.
References
Brock, W. A., Dechert, W. D., Scheinkman, J. A., & LeBaron, B. (1996). A test for independence based on the correlation dimension. Econometric Reviews, 15(3), 197-235.
Kanzler, L. (1999). Very fast and correctly sized estimation of the BDS statistic. Christ Church, University of Oxford, Working Paper.
Example
Gaussian noise keeps independence at every dimension; an ARCH process rejects it at every dimension, which is the pattern the Note describes:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> test = bds(rng.standard_normal(1000)) >>> test.dimension, test.reject(), [c.dimension for c in test.companions] (3, False, [2]) >>> e = np.zeros(1000) >>> for t in range(1, 1000): ... e[t] = np.sqrt(0.2 + 0.7 * e[t - 1] ** 2) * rng.standard_normal() >>> test = bds(e, dimension=4) >>> [round(c.pvalue, 4) for c in test.companions], round(test.pvalue, 4) ([0.0, 0.0], 0.0)
Private methods#
|
One table row: dimension, statistic, p-value. |
Render as a table over the embedding dimensions. |