Skip to contents

Control-function (residual augmentation) IV

Usage

morie_iv_control_function(
  data,
  outcome,
  endogenous,
  instruments,
  exogenous = NULL,
  robust = TRUE,
  alpha = 0.05
)

Arguments

data

Data frame.

outcome

Name of the outcome column.

endogenous

Character vector of endogenous regressor names.

instruments

Character vector of excluded-instrument names.

exogenous

Optional character vector of exogenous covariate names.

robust

Logical; if TRUE use HC1 robust standard errors.

alpha

Significance level for confidence intervals.

Value

A named list with elements coefficients, std_errors, t_stats, p_values, ci_lower, ci_upper, variable_names, n_obs, method, details.

Examples

set.seed(1); n <- 200
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)
morie_iv_control_function(df, "y", "d", "z")
#> $coefficients
#> (Intercept)           d  .cf_resid_ 
#>  0.00111613  0.45921304  0.23584925 
#> 
#> $std_errors
#> (Intercept)           d  .cf_resid_ 
#>   0.2616039   0.4433612   0.4544621 
#> 
#> $t_stats
#> (Intercept)           d  .cf_resid_ 
#> 0.004266491 1.035753838 0.518963517 
#> 
#> $p_values
#> (Intercept)           d  .cf_resid_ 
#>   0.9966002   0.3015867   0.6043687 
#> 
#> $ci_lower
#> (Intercept)           d  .cf_resid_ 
#>  -0.5147873  -0.4151302  -0.6603859 
#> 
#> $ci_upper
#> (Intercept)           d  .cf_resid_ 
#>   0.5170196   1.3335563   1.1320844 
#> 
#> $variable_names
#> [1] "(Intercept)" "d"           ".cf_resid_" 
#> 
#> $n_obs
#> [1] 200
#> 
#> $method
#> [1] "control function"
#> 
#> $details
#> $details$first_stage
#> 
#> Call:
#> stats::lm(formula = stats::as.formula(paste(e, "~", rhs)), data = data)
#> 
#> Coefficients:
#> (Intercept)            z  
#>      0.4694       0.2169  
#> 
#> 
#> $details$second_stage
#> 
#> Call:
#> stats::lm(formula = stats::as.formula(paste(outcome, "~", rhs2)), 
#>     data = data)
#> 
#> Coefficients:
#> (Intercept)            d   .cf_resid_  
#>    0.001116     0.459213     0.235849  
#> 
#> 
#>