arch.unitroot.VarianceRatio

class arch.unitroot.VarianceRatio(y: ndarray | DataFrame | Series, lags: int = 2, trend: 'n' | 'c' = 'c', debiased: bool = True, robust: bool = True, overlap: bool = True)[source]

Variance Ratio test of a random walk.

Parameters:
y: ndarray | DataFrame | Series

The data to test for a random walk

lags: int = 2

The number of periods to used in the multi-period variance, which is the numerator of the test statistic. Must be at least 2

trend: 'n' | 'c' = 'c'

“c” allows for a non-zero drift in the random walk, while “n” requires that the increments to y are mean 0

overlap: bool = True

Indicates whether to use all overlapping blocks. Default is True. If False, the number of observations in y minus 1 must be an exact multiple of lags. If this condition is not satisfied, some values at the end of y will be discarded.

robust: bool = True

Indicates whether to use heteroskedasticity robust inference. Default is True.

debiased: bool = True

Indicates whether to use a debiased version of the test. Default is True. Only applicable if overlap is True.

Notes

The null hypothesis of a VR is that the process is a random walk, possibly plus drift. Rejection of the null with a positive test statistic indicates the presence of positive serial correlation in the time series. See [1] for details about variance ratio testing.

Examples

>>> from arch.unitroot import VarianceRatio
>>> import pandas_datareader as pdr
>>> data = pdr.get_data_fred("DJIA", start="2010-1-1", end="2020-12-31")
>>> data = np.log(data.resample("M").last())  # End of month
>>> vr = VarianceRatio(data, lags=12)
>>> print(f"{vr.pvalue:0.4f}")
0.1370

References

Methods

summary()

Summary of test, containing statistic, p-value and critical values

Properties

alternative_hypothesis

The alternative hypothesis

critical_values

Dictionary containing critical values specific to the test, number of observations and included deterministic trend terms.

debiased

Sets of gets the indicator to use debiased variances in the ratio

lags

Sets or gets the number of lags used in the model.

nobs

The number of observations used when computing the test statistic.

null_hypothesis

The null hypothesis

overlap

Sets of gets the indicator to use overlapping returns in the long-period variance estimator

pvalue

Returns the p-value for the test statistic

robust

Sets of gets the indicator to use a heteroskedasticity robust variance estimator

stat

The test statistic for a unit root

trend

Sets or gets the deterministic trend term used in the test.

valid_trends

List of valid trend terms.

vr

The ratio of the long block lags-period variance to the 1-period variance

y

Returns the data used in the test statistic