LongitudinalRESIT

class lingam.LongitudinalRESIT(regressor, n_lags=1, prior_knowledge=None, prior_knowledge_lag=None, alpha=0.01, is_common_graph=True)[source]

Implementation of RESIT(regression with subsequent independence test) Algorithm [1] for longitudinal data

References

Notes

RESIT algorithm returns an adjacency matrix consisting of zeros or ones, rather than an adjacency matrix consisting of causal coefficients, in order to estimate nonlinear causality.

property A_list_

Estimated lag causal graphs.

If is_common_graph=True, a list of length 1. If is_common_graph=False, a list of length T; A_list_[0], …, A_list_[n_lags-1] are NaN tensors. Each element has shape (n_lags, n_vars, n_vars). A_list_[t][k, j, i] = 1 means there is an edge from variable i at k+1 time steps before time t to variable j at time t (k is 0-origin).

Returns:

A_list_

Return type:

list of ndarray

property B_list_

Estimated instantaneous causal graphs.

If is_common_graph=True, a list of length 1 (shared across all time points). If is_common_graph=False, a list of length T; B_list_[0], …, B_list_[n_lags-1] are NaN matrices. Each element has shape (n_vars, n_vars). B_list_[t][j, i] = 1 means there is an edge from variable i to variable j.

Returns:

B_list_

Return type:

list of ndarray

__init__(regressor, n_lags=1, prior_knowledge=None, prior_knowledge_lag=None, alpha=0.01, is_common_graph=True)[source]

Construct a LongitudinalRESIT model.

Parameters:
  • regressor (regressor object implementing 'fit' and 'predict' function (default=None)) – Regressor to compute residuals. This regressor object must have fit method and predict function like scikit-learn’s model.

  • n_lags (int, optional (default=1)) – Number of lags (past time points) to use. Must be an integer >= 1.

  • prior_knowledge (array-like, optional (default=None)) – Prior knowledge used for the instantaneous causal graph, assuming a common causal structure across all time points. A single matrix of shape (n_vars, n_vars). Values: 0=no edge, 1=edge exists, -1=unknown.

  • prior_knowledge_lag (array-like, optional (default=None)) – Prior knowledge used for the lag causal graph, assuming a common causal structure across all time points. A single tensor of shape (n_lags, n_vars, n_vars). Values: 0=no edge, 1=edge exists, -1=unknown.

  • alpha (float, optional (default=0.01)) – Alpha level for HSIC independence test when removing superfluous edges.

  • is_common_graph (bool, optional (default=True)) – If True, estimate a single causal graph shared across all time points. If False, estimate an independent causal graph for each time point.

property adjacency_matrices_

Estimated adjacency matrices combining instantaneous and lag graphs.

If is_common_graph=True, a list of length 1. If is_common_graph=False, a list of length T; adjacency_matrices_[0], …, adjacency_matrices_[n_lags-1] are NaN matrices. Each element has shape (n_vars, n_vars*(n_lags+1)). The first n_vars columns correspond to the instantaneous graph B, and the next n_vars columns correspond to A[0], and so on.

Returns:

adjacency_matrices_

Return type:

list of ndarray

bootstrap(X_list, n_sampling)[source]

Evaluate the statistical reliability of DAG based on the bootstrapping.

Parameters:
  • X_list (list of ndarray, shape [(n_samples, n_vars), ...]) – Multiple datasets for training, where each dataset corresponds to a time point. The length of X_list is T (number of time points). T >= 2 is required.

  • n_sampling (int) – Number of bootstrapping samples.

Returns:

results – Returns the results of bootstrapping for multiple datasets.

Return type:

LongitudinalRESITBootstrapResult

property causal_order_

Instantaneous causal order common to all time points.

Returns:

causal_order_ – The causal order of the fitted model, where the first element is the most upstream variable and the last is the sink.

Return type:

list of int

fit(X_list)[source]

Fit the model to X_list.

Parameters:

X_list (list of ndarray, shape [(n_samples, n_vars), ...]) – Multiple datasets for training, where each dataset corresponds to a time point. The length of X_list is T (number of time points). T >= 2 is required.

Returns:

self – Returns the instance itself.

Return type:

object