arch.unitroot.VarianceRatio

class arch.unitroot.VarianceRatio(y, lags=2, trend='c', debiased=True, robust=True, overlap=True)[source]

Variance Ratio test of a random walk.

Parameters
  • y ({ndarray, Series}) – The data to test for a random walk

  • lags (int) – 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"}, optional) – “c” allows for a non-zero drift in the random walk, while “n” requires that the increments to y are mean 0

  • overlap (bool, optional) – 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, optional) – Indicates whether to use heteroskedasticity robust inference. Default is True.

  • debiased (bool, optional) – 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.

Examples

>>> from arch.unitroot import VarianceRatio
>>> import datetime as dt
>>> import pandas_datareader as pdr
>>> data = pdr.get_data_fred("DJIA")
>>> data = data.resample("M").last()  # End of month
>>> returns = data["DJIA"].pct_change().dropna()
>>> vr = VarianceRatio(returns, lags=12)
>>> print("{0:0.4f}".format(vr.pvalue))
0.0000

References

*

Campbell, John Y., Lo, Andrew W. and MacKinlay, A. Craig. (1997) The Econometrics of Financial Markets. Princeton, NJ: Princeton University Press.

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