Skip to content

JohansenCointegration

JohansenCointegration

class JohansenCointegration(det_order=1, k_ar_diff=1)[source]

Test for cointegration ranks/relationships for VECM Time-Series.

Direct interface to statsmodels.tsa.vector_ar.vecm.

The Johansen Cointegration test is a test solely used in Vector Error Correction Models (VECM) to determine the occurrence of a long-term relationship (cointegration rank) between two time series or several long-term relationships in case of multiple time-series. The idea of the underlying test is to estimate, if such (a) relationship(s) exist(s). In case there is a relationship (or several), the time series used in the model, can be in its original scale in levels without dedifferencing them. Normally, time series not being stationary need to be ‘integrated’(dedifferenced) before using them in time series analysis, e.g. VAR or ARIMA.If however, (a) long-term relationship(s) exist(s), that means that the variables inthe ‘long term’ are stationary ‘together’, and can be used without any transformation. If no relationship (no cointegration rank) is found, a VECM can not be used and a VAR needs to considered but with integrated/dedifferenced time-series. The estimator used in the code determines the coint parameter value to be used in VECM time-series module/estimator vecm.py: coint_rank. Use trace statistics or eigenvalue to find it.

Parameters:
det_orderint, default=1
  • -1 - no deterministic terms

  • 0 - constant term

  • 1 - linear trend

k_ar_diffint, nonnegative, default=1

Number of lagged differences in the model. Needs multivariate version of ARLagOrderSelector, See also: statsmodels.tsa.vector_ar.vecm.select_order

Attributes:
cvm_np.ndarray of float containing critical values

(90%, 95%, 99%) of maximum eigenvalue statistic

cvt_np.ndarray of float containing critical values

(90%, 95%, 99%) of trace statistic

eig_np.ndarray of float containing eigenvalues of VECM coefficient matrix
evec_np.ndarray of float containing eigenvectors of VECM coefficient matrix
ind_np.ndarray of int containing Order of eigenvalues
lr1_np.ndarray of float containing trace statistic
lr2_np.ndarray of float containing maximum eigenvalue statistic
max_eig_stat_np.ndarray of float containing maximum eigenvalue statistic

(Needs to be tested, because it seems to be a duplicate in statsmodels)

max_eig_stat_crit_vals_np.ndarray of float containing critical values

(90%, 95%, 99%) of maximum eigenvalue statistic

meth_str containing the name of the test method
r0t_np.ndarray of float containing residuals for delta Y
rkt_np.ndarray of float containing residuals for delta Y-1
trace_stat_np.ndarray of float containing trace statistics
trace_stat_crit_vals_np.ndarray of float containing critical values

(90%, 95%, 99%) of trace statistic

Notes

The underlying test is a wrapper for the statsmodels cointegration test. The max rank (depending on preferred sig-level) needs to be derived from the param estimates and be used as coint-rank. for the other parameters, it is advised to choose the same det_order as in the main model. Same goes for k_ar_diff and max lag determined. Further, keep in mind, X in this case needs to be a minimum of two times series, where X may equal x AND y. VECM do not have a classical X and a y series. Both are to be considered endogenous.

References

[1]

Lütkepohl, H. 2005. New Introduction to Multiple Time Series Analysis. Springer.

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.param_est.cointegration import JohansenCointegration
>>> import pandas as pd
>>> X = load_airline()
>>> X2 = X.shift(1).bfill()
>>> df = pd.DataFrame({"X":X, "X2": X2})
>>> coint_est = JohansenCointegration()
>>> coint_est.fit(df)
JohansenCointegration(...)
>>> print(coint_est.get_fitted_params()["cvm"])
[[15.0006 17.1481 21.7465]
 [ 2.7055  3.8415  6.6349]]

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(X[, y])

Fit estimator and estimate parameters.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator/test.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

update(X[, y])

Update fitted parameters on more data.