Skip to contents

DoWhy-style robustness checks, all native: a placebo (permuted) treatment should give an effect near zero; adding a random common cause or re-estimating on subsets should leave the estimate stable.

Usage

morie_dag_refute(
  dag,
  data,
  method = c("placebo_treatment", "random_common_cause", "data_subset"),
  estimator = "backdoor.linear",
  n_reps = 20L,
  seed = 42L
)

Arguments

dag

A morie_dag.

data

The data frame used for estimation.

method

One of "placebo_treatment", "random_common_cause", "data_subset".

estimator

Passed through to morie_dag_estimate().

n_reps

Number of refutation replications (default 20).

seed

Random seed.

Value

List with original, refuted (mean over reps), reps, passed (logical heuristic), method.

Examples

set.seed(1)
z <- rnorm(400); x <- rbinom(400, 1, plogis(z))
y <- 0.8 * x + z + rnorm(400)
df <- data.frame(z = z, x = x, y = y)
g <- morie_dag(c("z -> x", "z -> y", "x -> y"), "x", "y")
morie_dag_refute(g, df, method = "placebo_treatment",
                 estimator = "backdoor.linear", n_reps = 5)
#> $original
#> [1] 0.8599143
#> 
#> $refuted
#> [1] -0.03681865
#> 
#> $reps
#> [1]  0.031018816  0.141159928 -0.100545748 -0.247965756 -0.007760502
#> 
#> $passed
#> [1] TRUE
#> 
#> $method
#> [1] "placebo_treatment"
#>