LongitudinalLiNGAM
- class lingam.LongitudinalLiNGAM(n_lags=1, measure='pwling', random_state=None)[source]
Implementation of Longitudinal LiNGAM algorithm [1]
References
- __init__(n_lags=1, measure='pwling', random_state=None)[source]
Construct a model.
- Parameters:
n_lags (int, optional (default=1)) – Number of lags.
measure ({'pwling', 'kernel'}, default='pwling') – Measure to evaluate independence : ‘pwling’ or ‘kernel’.
random_state (int, optional (default=None)) –
random_state
is the seed used by the random number generator.
- property adjacency_matrices_
Estimated adjacency matrices.
- Returns:
adjacency_matrices_ – The list of adjacency matrix B(t,t) and B(t,t-τ) for longitudinal datasets. The shape of B(t,t) and B(t,t-τ) is (n_features, n_features), where
n_features
is the number of features. If the previous data required for the calculation are not available, such as B(t,t) or B(t,t-τ) at t=0, all elements of the matrix are nan.- Return type:
array-like, shape ((B(t,t), B(t,t-1), …, B(t,t-τ)), …)
- bootstrap(X_list, n_sampling, start_from_t=1)[source]
Evaluate the statistical reliability of DAG based on the bootstrapping.
- Parameters:
X_list (array-like, shape (X, ...)) – Longitudinal multiple datasets for training, where
X
is an dataset. The shape of ‘’X’’ is (n_samples, n_features), wheren_samples
is the number of samples andn_features
is the number of features.n_sampling (int) – Number of bootstrapping samples.
- Returns:
results – Returns the results of bootstrapping for multiple datasets.
- Return type:
array-like, shape (BootstrapResult, …)
- property causal_orders_
Estimated causal ordering.
- Returns:
causal_order_ – The causal order of fitted models for B(t,t). The shape of causal_order is (n_features), where
n_features
is the number of features.- Return type:
array-like, shape (causal_order, …)
- estimate_total_effect(X_t, from_t, from_index, to_t, to_index)[source]
Estimate total effect using causal model.
- Parameters:
X_t (array-like, shape (timepoint, n_samples, n_features)) – Original data, where n_samples is the number of samples and n_features is the number of features.
_t (from) – The timepoint of source variable.
from_index – Index of source variable to estimate total effect.
to_t – The timepoint of destination variable.
to_index – Index of destination variable to estimate total effect.
- Returns:
total_effect – Estimated total effect.
- Return type:
float
- estimate_total_effect2(from_t, from_index, to_t, to_index)[source]
Estimate total effect using causal model.
- Parameters:
_t (from) – The timepoint of source variable.
from_index – Index of source variable to estimate total effect.
to_t – The timepoint of destination variable.
to_index – Index of destination variable to estimate total effect.
- Returns:
total_effect – Estimated total effect.
- Return type:
float
- fit(X_list)[source]
Fit the model to datasets.
- Parameters:
X_list (list, shape [X, ...]) – Longitudinal multiple datasets for training, where
X
is an dataset. The shape ofX
is (n_samples, n_features), wheren_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
E
is an dataset. The shape ofE
is (n_samples, n_features), wheren_samples
is the number of samples andn_features
is the number of features.- Return type:
list, shape [E, …]