Skip to contents

Given a causal DAG and observed data, tests all conditional independence relationships implied by the DAG's d-separation structure. Useful for evaluating whether the assumed DAG is compatible with the data.

Usage

dag_test_implications(dag_string, data, alpha = 0.05)

Arguments

dag_string

Character or dagitty object. The causal DAG.

data

A data frame. Variable names must match node names in the DAG.

alpha

Numeric. Significance level. Default 0.05.

Value

A data frame with columns: x, y, conditioning_set, p_value, rejected (whether the independence is rejected at alpha).

Examples

if (FALSE) { # \dontrun{
dag <- "dag{ X -> Y; Z -> X; Z -> Y }"
set.seed(1)
n   <- 300
Z   <- rnorm(n)
X   <- 0.5 * Z + rnorm(n)
Y   <- 0.3 * X + 0.4 * Z + rnorm(n)
df  <- data.frame(X = X, Y = Y, Z = Z)
dag_test_implications(dag, df)
} # }