Wraps DoubleML when available. Otherwise falls back to 2SLS:
first stage D ~ Z + X, second stage Y ~ D_hat + X, base R OLS.
Usage
estimate_pliv(
data,
treatment,
outcome,
instrument,
covariates,
n_folds = 5L,
random_state = 42L
)Examples
set.seed(1)
n <- 80
x1 <- rnorm(n); x2 <- rnorm(n); z <- rbinom(n, 1, 0.5)
d <- as.integer(plogis(0.3 + 0.8 * z + 0.4 * x1) > runif(n))
y <- 1 + 0.5 * d + 0.3 * x1 + rnorm(n)
df <- data.frame(y, d, z, x1, x2)
res <- suppressWarnings(estimate_pliv(df, "d", "y", "z", c("x1", "x2")))
res$late
#> [1] 4.354738
