VAR-LiNGAM
- class lingam.VARLiNGAM(lags=1, criterion='bic', prune=True, ar_coefs=None, lingam_model=None, random_state=None)[source]
Implementation of VAR-LiNGAM Algorithm [1]
References
- __init__(lags=1, criterion='bic', prune=True, ar_coefs=None, lingam_model=None, random_state=None)[source]
Construct a VARLiNGAM model.
- Parameters:
lags (int, optional (default=1)) – Number of lags.
criterion ({‘aic’, ‘fpe’, ‘hqic’, ‘bic’, None}, optional (default='bic')) – Criterion to decide the best lags within
lags
. Searching the best lags is disabled ifcriterion
isNone
.prune (boolean, optional (default=True)) – Whether to prune the adjacency matrix of lags.
ar_coefs (array-like, optional (default=None)) – Coefficients of AR model. Estimating AR model is skipped if specified
ar_coefs
. Shape must be (lags
, n_features, n_features).lingam_model (lingam object inherits 'lingam._BaseLiNGAM', optional (default=None)) – LiNGAM model for causal discovery. If None, DirectLiNGAM algorithm is selected.
random_state (int, optional (default=None)) –
random_state
is the seed used by the random number generator.
- property adjacency_matrices_
Estimated adjacency matrix.
- Returns:
adjacency_matrices_ – The adjacency matrix of fitted model, where n_features is the number of features.
- Return type:
array-like, shape (lags, n_features, n_features)
- bootstrap(X, n_sampling)[source]
Evaluate the statistical reliability of DAG based on the bootstrapping.
- Parameters:
X (array-like, shape (n_samples, n_features)) – Training data, where
n_samples
is the number of samples andn_features
is the number of features.n_sampling (int) – Number of bootstrapping samples.
- Returns:
result – Returns the result of bootstrapping.
- Return type:
TimeseriesBootstrapResult
- property causal_order_
Estimated causal ordering.
- Returns:
causal_order_ – The causal order of fitted model, where n_features is the number of features.
- Return type:
array-like, shape (n_features)
- estimate_total_effect(X, from_index, to_index, from_lag=0)[source]
Estimate total effect using causal model.
- Parameters:
X (array-like, shape (n_samples, n_features)) – Original data, where n_samples is the number of samples and n_features is the number of features.
from_index – Index of source variable to estimate total effect.
to_index – Index of destination variable to estimate total effect.
- Returns:
total_effect – Estimated total effect.
- Return type:
float
- estimate_total_effect2(n_features, from_index, to_index, from_lag=0)[source]
Estimate total effect using causal model.
- Parameters:
n_features – The number of features.
from_index – Index of source variable to estimate total effect.
to_index – Index of destination variable to estimate total effect.
- Returns:
total_effect – Estimated total effect.
- Return type:
float
- fit(X)[source]
Fit the model to X.
- Parameters:
X (array-like, shape (n_samples, n_features)) – Training data, where
n_samples
is the number of samples andn_features
is the number of features.- Returns:
self – Returns the instance itself.
- Return type:
object
- get_error_independence_p_values()[source]
Calculate the p-value matrix of independence between error variables.
- Returns:
independence_p_values – p-value matrix of independence between error variables.
- Return type:
array-like, shape (n_features, n_features)
- property residuals_
Residuals of regression.
- Returns:
residuals_ – Residuals of regression, where n_samples is the number of samples.
- Return type:
array-like, shape (n_samples)