PC

Algorithm Introduction

Perform Peter-Clark (PC 1) algorithm for causal discovery. We also allowed data sets with missing values, for which testwise-deletion PC is included (choosing ‘MV-Fisher_Z” for the test name).

If you would like to use missing-value PC 2, please set ‘mvpc’ as True.

Usage

```from causallearn.search.ConstraintBased.PC import pc
G = pc(data, alpha, indep_test, stable, uc_rule, uc_priority, mvpc, correction_name, background_knowledge)

# visualization using pydot
cg.draw_pydot_graph()

# visualization using networkx
# cg.to_nx_graph()
# cg.draw_nx_graph(skel=False)
```

Parameters

data: numpy.ndarray, shape (n_samples, n_features). Data, where n_samples is the number of samples and n_features is the number of features.

alpha: desired significance level (float) in (0, 1).

indep_test: Independence test method function.
• fisherz”: Fisher’s Z conditional independence test.

• chisq”: Chi-squared conditional independence test.

• gsq”: G-squared conditional independence test.

• kci”: kernel-based conditional independence test. (As a kernel method, its complexity is cubic in the sample size, so it might be slow if the same size is not small.)

• mv_fisherz”: Missing-value Fisher’s Z conditional independence test.

stable: run stabilized skeleton discovery if True (default = True).

uc_rule: how unshielded colliders are oriented.
• 0: run uc_sepset.

• 1: run maxP. Orient an unshielded triple X-Y-Z as a collider with an aditional CI test.

• 2: run definiteMaxP. Orient only the definite colliders in the skeleton and keep track of all the definite non-colliders as well.

uc_priority: rule of resolving conflicts between unshielded colliders.
• -1: whatever is default in uc_rule.

• 0: overwrite.

• 1: orient bi-directed.

• 2: prioritize existing colliders.

• 3: prioritize stronger colliders.

• 4: prioritize stronger* colliders.

mvpc: use missing-value PC or not. Default: False.

correction_name. Missing value correction if using missing-value PC. Default: ‘MV_Crtn_Fisher_Z’

background_knowledge: class BackgroundKnowledge. Add prior edges according to assigned causal connections. For detailed usage, please kindly refer to its usage example.

Returns

cg : a CausalGraph object. Nodes in the graph correspond to the column indices in the data.

1

Spirtes, P., Glymour, C. N., Scheines, R., & Heckerman, D. (2000). Causation, prediction, and search. MIT press.

2

Tu, R., Zhang, C., Ackermann, P., Mohan, K., Kjellström, H., & Zhang, K. (2019, April). Causal discovery in the presence of missing data. In The 22nd International Conference on Artificial Intelligence and Statistics (pp. 1762-1770). PMLR.