IV residual analysis
Arguments
- data
A
data.frame(or tibble) holding the outcome, endogenous regressors, instruments, and any exogenous controls.- outcome
Character; column name of the response variable.
- endogenous
Character vector; column names of the endogenous regressors.
- instruments
Character vector; column names of the instrumental variables.
- exogenous
Optional character vector of additional exogenous regressors included in both the structural equation and the first stage.
NULL(default) for a just-identified design.
Examples
set.seed(1)
n <- 400
z <- rbinom(n, 1, 0.5); u <- rnorm(n)
d <- rbinom(n, 1, plogis(0.8 * z + 0.3 * u))
y <- 0.5 * d + 0.4 * u + rnorm(n, sd = 0.5)
df <- data.frame(y, d, z)
out <- morie_iv_residual_analysis(df, "y", "d", "z")
head(out)
#> fitted residual abs_resid sq_resid
#> 1 0.50818356 -0.38787723 0.38787723 0.150448749
#> 2 -0.05005272 -0.18743947 0.18743947 0.035133556
#> 3 -0.05005272 1.18232900 1.18232900 1.397901855
#> 4 -0.05005272 -0.08824129 0.08824129 0.007786526
#> 5 0.50818356 -1.22209197 1.22209197 1.493508792
#> 6 -0.05005272 0.96014336 0.96014336 0.921875275
