Augmented Dickey-Fuller test for a unit root in a univariate time series.
Augmented Dickey-Fuller test for a unit root in a univariate time series.
The null hypothesis is that the time series contains a unit root, implying that differencing is required to make it stationary. The alternative hypothesis is that the time series is stationary. Lower values of the test statistic imply lower p-values, and thus higher likelihood of rejecting the null hypothesis.
The time series.
A tuple containing the test statistic and p value.
Breusch-Godfrey test for serial correlation in a model The statistic asymptotically follows an X2 distribution with maxLag degrees of freedom, and provides a test for the null hypothesis of lack of serial correlation up to degree maxLag From http://en.wikipedia.org/wiki/Breusch%E2%80%93Godfrey_test: Given estimated residuals u_hat_t from an OLS model of the form y_t = a0 + a1 * x1_t + a2 * x2_t + ... + u_t We calculate an auxiliary regression of the form: u_hat_t = a0 + a1 * x1_t + a2 * x2_t + ... + p1 * u_hat_t-1 + p2 * u_hat_t-2 ... Our test statistic is then (# of obs - maxLag) * (R2 of the auxiliary regression)
Breusch-Godfrey test for serial correlation in a model The statistic asymptotically follows an X2 distribution with maxLag degrees of freedom, and provides a test for the null hypothesis of lack of serial correlation up to degree maxLag From http://en.wikipedia.org/wiki/Breusch%E2%80%93Godfrey_test: Given estimated residuals u_hat_t from an OLS model of the form y_t = a0 + a1 * x1_t + a2 * x2_t + ... + u_t We calculate an auxiliary regression of the form: u_hat_t = a0 + a1 * x1_t + a2 * x2_t + ... + p1 * u_hat_t-1 + p2 * u_hat_t-2 ... Our test statistic is then (# of obs - maxLag) * (R2 of the auxiliary regression)
The Breusch-Godfrey statistic and p value
Breusch-Pagan test for heteroskedasticity in a model The statistic follows a X2 distribution with (# of regressors - 1) degrees of freedom and provides a test for a null hypothesis of homoskedasticity From http://en.wikipedia.org/wiki/Breusch%E2%80%93Pagan_test Given a vector of estimated residuals (u) from an OLS model, we create an auxiliary regression that models the squared residuals (u2) as a function of the original regressors (X) u2 = beta * X We construct our test statistic as (# of observations) * R2 of our auxiliary regression
Breusch-Pagan test for heteroskedasticity in a model The statistic follows a X2 distribution with (# of regressors - 1) degrees of freedom and provides a test for a null hypothesis of homoskedasticity From http://en.wikipedia.org/wiki/Breusch%E2%80%93Pagan_test Given a vector of estimated residuals (u) from an OLS model, we create an auxiliary regression that models the squared residuals (u2) as a function of the original regressors (X) u2 = beta * X We construct our test statistic as (# of observations) * R2 of our auxiliary regression
The Breusch-Pagan statistic and p value
Durbin-Watson test for serial correlation.
Durbin-Watson test for serial correlation.
The Durbin-Watson test statistic. A value close to 0.0 gives evidence for positive serial correlation, a value close to 4.0 gives evidence for negative serial correlation, and a value close to 2.0 gives evidence for no serial correlation.
Performs the KPSS stationarity test (Kwiatkowski, Phillips, Schmidt and Shin).
Performs the KPSS stationarity test (Kwiatkowski, Phillips, Schmidt and Shin). The null hypothesis corresponds to stationarity (level stationarity if method = "c", or trend stationarity if method = "ct"). If method = "c", a regression of the form ts_i = alpha + error_i is fit. If method = "ct", a regression of the form ts_i = alpha + beta * i + error_i. The test then performs a check for the variance of the errors. The null hypothesis of stationarity corresponds to a null hypothesis of variance = 0 for the errors. For more information please see pg 129 of http://faculty.washington .edu/ezivot/econ584/notes/unitroot.pdf. For the original paper on the test, please see http://www.deu.edu.tr/userweb/onder.hanedar/dosyalar/kpss.pdf. Finally, the current implementation follows R's tseries package implementation closely, which can be found at https://cran.r-project.org/web/packages/tseries/index.html
time series to test for stationarity
"c" or "ct", short for fitting with a constant or a constant and a time trend
the KPSS statistic and a map of critical values according to the method selected
Ljung-Box test for serial correlation in residuals up to lag maxLag
.
Ljung-Box test for serial correlation in residuals up to lag maxLag
. The null hypothesis
is that values are independently distributed up to the given lag. The alternate hypothesis
is that serial correlation is present. The test statistic follows a Chi-Squared distribution
with maxLag
degrees of freedom. See https://en.wikipedia.org/wiki/Ljung%E2%80%93Box_test
for more information.
the test statistic and the p-value associated with it.
Adapted from statsmodels: https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/stattools.py https://github.com/statsmodels/statsmodels/blob/master/statsmodels/tsa/adfvalues.py