Causality, Causal Inference, Backdoor, Frontdoor, Instrumental Variable.
is called two-stage regression, where at the first stage we regress X on the instrument IV, and on the second stage, we regress the outcome Y on the residuals from the first stage. stage1_fit <- stats::lm(x~iv, data = df) df$stage1_predict <- predict(stage1_fit, type = “response”) stage2_fit <-