Time series tests

Time series tests

Durbin-Watson test

DurbinWatsonTest(X::AbstractArray, e::AbstractVector; p_compute::Symbol = :ndep)

Compute the Durbin-Watson test for serial correlation in the residuals of a regression model.

X is the matrix of regressors from the original regression model and e the vector of residuals. Note that the Durbin-Watson test is not valid if X includes a lagged dependent variable. The test statistic is computed as

$DW = \frac{\sum_{t=2}^n (e_t - e_{t-1})^2}{\sum_{t=1}^n e_t^2}$

where n is the number of observations.

By default, the choice of approach to compute p-values depends on the sample size (p_compute=:ndep). For small samples (n<100), Pan's algorithm (Farebrother, 1980) is employed. For larger samples, a normal approximation is used (Durbin and Watson, 1950). To always use Pan's algorithm, set p_compute=:exact. p_compute=:approx will always use the normal approximation.

Default is a two-sided p-value for the alternative hypothesis of positive or negative serial correlation. One-sided p-values can be requested by calling pvalue(x::DurbinWatsonTest; tail=) with the options :left (negative serial correlation) and :right (positive serial correlation).

References

• J. Durbin and G. S. Watson, 1951, "Testing for Serial Correlation in Least Squares Regression: II", Biometrika, Vol. 38, No. 1/2, pp. 159-177, http://www.jstor.org/stable/2332325.
• J. Durbin and G. S. Watson, 1950, "Testing for Serial Correlation in Least Squares Regression: I", Biometrika, Vol. 37, No. 3/4, pp. 409-428, http://www.jstor.org/stable/2332391.
• R. W. Farebrother, 1980, "Algorithm AS 153: Pan's Procedure for the Tail Probabilities of the Durbin-Watson Statistic", Journal of the Royal Statistical Society, Series C (Applied Statistics), Vol. 29, No. 2, pp. 224-227, http://www.jstor.org/stable/2986316.

source

Box-Pierce and Ljung-Box tests

BoxPierceTest(y, lag, dof=0)

Compute the Box-Pierce Q statistic to test the null hypothesis of independence in a time series y.

lag specifies the number of lags used in the construction of Q. When testing the residuals of an estimated model, dof has to be set to the number of estimated parameters. E.g., when testing the residuals of an ARIMA(p,0,q) model, set dof=p+q.

source
LjungBoxTest(y, lag, dof=0)

Compute the Ljung-Box Q statistic to test the null hypothesis of independence in a time series y.

lag specifies the number of lags used in the construction of Q. When testing the residuals of an estimated model, dof has to be set to the number of estimated parameters. E.g., when testing the residuals of an ARIMA(p,0,q) model, set dof=p+q.

source

Breusch-Godfrey test

BreuschGodfreyTest(X, e, lag, start0 = true)

Compute the Breusch-Godfrey test for serial correlation in the residuals of a regression model.

X is the matrix of regressors from the original model and e the vector of residuals. lag determines the number of lagged residuals included in the auxiliary regression. Set start0 to specify how the starting values for the lagged residuals are handled. start0 = true (default) sets them to zero (as in Godfrey, 1978); start0 = false uses the first lag residuals as starting values, i.e. shortening the sample by lag.

source

Jarque-Bera test

JarqueBeraTest(y::AbstractVector)

Compute the Jarque-Bera statistic to test the null hypothesis that a real-valued vector y is normally distributed.

Note that the approximation by the Chi-squared distribution does not work well and the speed of convergence is slow. In small samples, the test tends to be over-sized for nominal levels up to about 3% and under-sized for larger nominal levels (Mantalos, 2010).

References

• Panagiotis Mantalos, 2011, "The three different measures of the sample skewness and kurtosis and the effects to the Jarque-Bera test for normality", International Journal of Computational Economics and Econometrics, Vol. 2, No. 1, link.

source

Augmented Dickey-Fuller test

ADFTest(y, deterministic, lag)

Compute the augmented Dickey-Fuller unit root test.

y is the time series to be tested, deterministic determines the deterministic terms (options: none, constant, trend, squared_trend) and lag the number of lagged first-differences included in the test regression, respectively.

Critical values and asymptotic p-values are computed based on response surface regressions following MacKinnon (2010) and MacKinnon (1994), respectively. These may differ slightly from those reported in other regression packages as different algorithms might be used.

References

• James G. MacKinnon, 2010, "Critical values for cointegration tests," QED Working Paper No. 1227, 2010, link.
• James G. MacKinnon, 1994, "Approximate Asymptotic Distribution Functions for Unit-Root and Cointegration Tests", Journal of Business & Economic Statistics, Vol. 12, No. 2, pp. 167-176, link.