RCD

class lingam.RCD(max_explanatory_num=2, cor_alpha=0.01, ind_alpha=0.01, shapiro_alpha=0.01, MLHSICR=False, bw_method='mdbs', independence='hsic', ind_corr=0.5)[source]

Implementation of RCD Algorithm [1]

References

__init__(max_explanatory_num=2, cor_alpha=0.01, ind_alpha=0.01, shapiro_alpha=0.01, MLHSICR=False, bw_method='mdbs', independence='hsic', ind_corr=0.5)[source]

Construct a RCD model.

Parameters:
• max_explanatory_num (int, optional (default=2)) – Maximum number of explanatory variables.

• cor_alpha (float, optional (default=0.01)) – Alpha level for pearson correlation.

• ind_alpha (float, optional (default=0.01)) – Alpha level for HSIC.

• shapiro_alpha (float, optional (default=0.01)) – Alpha level for Shapiro-Wilk test.

• MLHSICR (bool, optional (default=False)) – If True, use MLHSICR for multiple regression, if False, use OLS for multiple regression.

• bw_method (str, optional (default=``mdbs``)) –

The method used to calculate the bandwidth of the HSIC.

• `mdbs` : Median distance between samples.

• `scott` : Scott’s Rule of Thumb.

• `silverman` : Silverman’s Rule of Thumb.

• independence ({'hsic', 'fcorr'}, optional (default='hsic')) – Methods to determine independence. If ‘hsic’ is set, test for independence by HSIC. If ‘fcorr’ is set, independence is determined by F-correlation.

• ind_corr (float, optional (default=0.5)) – The threshold value for determining independence by F-correlation; independence is determined when the value of F-correlation is below this threshold value.

Returns:

adjacency_matrix_ – The adjacency matrix B of fitted model, where n_features is the number of features. Set np.nan if order is unknown.

Return type:

array-like, shape (n_features, n_features)

property ancestors_list_

Estimated ancestors list.

Returns:

ancestors_list_ – The list of causal ancestors sets, where n_features is the number of features.

Return type:

array-like, shape (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 and `n_features` is the number of features.

• n_sampling (int) – Number of bootstrapping samples.

Returns:

result – Returns the result of bootstrapping.

Return type:

BootstrapResult

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 and `n_features` is the number of features.

Returns:

self – Returns the instance itself.

Return type:

object

get_error_independence_p_values(X)[source]

Calculate the p-value matrix of independence between error variables.

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.

Returns:

independence_p_values – p-value matrix of independence between error variables.

Return type:

array-like, shape (n_features, n_features)