iv_est {CausalModels}R Documentation

Standard Instrumental Variable Estimator

Description

'iv_est' calculates the standard IV estimand using the conditional means on a given instrumental variable.

Usage

iv_est(IV, data, n.boot = 50)

Arguments

IV

the instrumental variable to be used in the conditional means. Must be a factor with no more than 2 levels. It is assumed the second level is the positive level, i.e., the binary equivalent of the second factor level should be 1 and the first should be 0.

data

a data frame containing the variables in the model. This should be the same data used in init_params.

n.boot

an integer value that indicates number of bootstrap iterations to calculate standard error.

Value

iv_est returns a data frame containing the standard IV estimate, standard error, and Wald 95

Examples

library(causaldata)
data(nhefs)
nhefs.nmv <- nhefs[which(!is.na(nhefs$wt82)), ]
nhefs.nmv$qsmk <- as.factor(nhefs.nmv$qsmk)

confounders <- c(
  "sex", "race", "age", "education", "smokeintensity",
  "smokeyrs", "exercise", "active", "wt71"
)
nhefs.iv <- nhefs[which(!is.na(nhefs$wt82) & !is.na(nhefs$price82)), ]
nhefs.iv$highprice <- as.factor(ifelse(nhefs.iv$price82 >= 1.5, 1, 0))
nhefs.iv$qsmk <- as.factor(nhefs.iv$qsmk)
init_params(wt82_71, qsmk,
            covariates = confounders,
            data = nhefs.iv)

iv_est("highprice", nhefs.iv)

[Package CausalModels version 0.2.0 Index]