Title: | Estimation of Marginal Treatment Effects using Local Instrumental Variables |
---|---|
Description: | In the generalized Roy model, the marginal treatment effect (MTE) can be used as a building block for constructing conventional causal parameters such as the average treatment effect (ATE) and the average treatment effect on the treated (ATT). Given a treatment selection equation and an outcome equation, the function mte() estimates the MTE via the semiparametric local instrumental variables method or the normal selection model. The function mte_at() evaluates MTE at different values of the latent resistance u with a given X = x, and the function mte_tilde_at() evaluates MTE projected onto the estimated propensity score. The function ace() estimates population-level average causal effects such as ATE, ATT, or the marginal policy relevant treatment effect. |
Authors: | Xiang Zhou [aut, cre] |
Maintainer: | Xiang Zhou <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.3.1 |
Built: | 2025-02-18 04:41:45 UTC |
Source: | https://github.com/xiangzhou09/localiv |
ace
estimates Average Causal Effects (ACE) from a fitted MTE model.
The estimand can be average treatment effect (ATE), average treatment effect on the treated (ATT),
average treatment effect on the untreated (ATU), or the Marginal Policy Relevant
Treatment Effect (MPRTE) defined in Zhou and Xie (2019).
ace(model, estimand = c("ate", "att", "atu", "mprte"), policy = 1)
ace(model, estimand = c("ate", "att", "atu", "mprte"), policy = 1)
model |
A fitted |
estimand |
Type of estimand: |
policy |
An |
Estimate of ATE, ATT, ATU, or MPRTE
Heckman, James J., Sergio Urzua, and Edward Vytlacil. 2006. "Understanding Instrumental Variables in Models with Essential Heterogeneity." The Review of Economics and Statistics 88:389-432.
Zhou, Xiang and Yu Xie. 2019. "Marginal Treatment Effects from A Propensity Score Perspective." Journal of Political Economy, 127(6): 3070-3084.
Zhou, Xiang and Yu Xie. 2020. "Heterogeneous Treatment Effects in the Presence of Self-selection: a Propensity Score Perspective." Sociological Methodology.
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) ate <- ace(mod, "ate") att <- ace(mod, "att") atu <- ace(mod, "atu") mprte1 <- ace(mod, "mprte") mprte2 <- ace(mod, "mprte", policy = p) mprte3 <- ace(mod, "mprte", policy = 1-p) mprte4 <- ace(mod, "mprte", policy = I(p<0.25)) c(ate, att, atu, mprte1, mprte2, mprte3, mprte4)
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) ate <- ace(mod, "ate") att <- ace(mod, "att") atu <- ace(mod, "atu") mprte1 <- ace(mod, "mprte") mprte2 <- ace(mod, "mprte", policy = p) mprte3 <- ace(mod, "mprte", policy = 1-p) mprte4 <- ace(mod, "mprte", policy = I(p<0.25)) c(ate, att, atu, mprte1, mprte2, mprte3, mprte4)
mte
fits a MTE model using either the semiparametric local instrumental
variables (local IV) method or the normal selection model (Heckman, Urzua, Vytlacil 2006).
The user supplies a formula for the treatment selection equation, a formula for the
outcome equations, and a data frame containing all variables. The function returns an
object of class mte
. Observations that contain NA (either in selection
or
in outcome
) are removed.
mte( selection, outcome, data = NULL, method = c("localIV", "normal"), bw = NULL ) mte_localIV(mf_s, mf_o, bw = NULL) mte_normal(mf_s, mf_o)
mte( selection, outcome, data = NULL, method = c("localIV", "normal"), bw = NULL ) mte_localIV(mf_s, mf_o, bw = NULL) mte_normal(mf_s, mf_o)
selection |
A formula representing the treatment selection equation. |
outcome |
A formula representing the outcome equations where the left hand side is the observed outcome and the right hand side includes predictors of both potential outcomes. |
data |
A data frame, list, or environment containing the variables in the model. |
method |
How to estimate the model: either " |
bw |
Bandwidth used for the local polynomial regression in the local IV approach. Default is 0.25. |
mf_s |
A model frame for the treatment selection equations returned by
|
mf_o |
A model frame for the outcome equations returned by
|
mte_localIV
estimates using the semiparametric local IV method,
and
mte_normal
estimates using the normal selection model.
An object of class mte
.
coefs |
A list of coefficient estimates: |
ufun |
A function representing the unobserved component of |
ps |
Estimated propensity scores. |
ps_model |
The propensity score model, an object of class |
mf_s |
The model frame for the treatment selection equation. |
mf_o |
The model frame for the outcome equations. |
complete_row |
A logical vector indicating whether a row is complete (no missing variables) in the
original |
call |
The matched call. |
Heckman, James J., Sergio Urzua, and Edward Vytlacil. 2006. "Understanding Instrumental Variables in Models with Essential Heterogeneity." The Review of Economics and Statistics 88:389-432.
mte_at
for evaluating MTE at different values of the latent resistance ;
mte_tilde_at
for evaluating MTE projected onto the propensity score;
ace
for estimating average causal effects from a fitted mte
object.
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata, bw = 0.25) summary(mod$ps_model) hist(mod$ps) mte_vals <- mte_at(u = seq(0.05, 0.95, 0.1), model = mod) if(require("ggplot2")){ ggplot(mte_vals, aes(x = u, y = value)) + geom_line(size = 1) + xlab("Latent Resistance U") + ylab("Estimates of MTE at Mean Values of X") + theme_minimal(base_size = 14) }
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata, bw = 0.25) summary(mod$ps_model) hist(mod$ps) mte_vals <- mte_at(u = seq(0.05, 0.95, 0.1), model = mod) if(require("ggplot2")){ ggplot(mte_vals, aes(x = u, y = value)) + geom_line(size = 1) + xlab("Latent Resistance U") + ylab("Estimates of MTE at Mean Values of X") + theme_minimal(base_size = 14) }
mte_at
evaluates marginal treatment effects at different
values of the latent resistance u
with a given .
mte_at(x = NULL, u, model)
mte_at(x = NULL, u, model)
x |
Values of the pretreatment covariates at which |
u |
A numeric vector. Values of the latent resistance |
model |
A fitted MTE model returned by |
mte_at
returns a data frame.
u |
input values of |
x_comp |
the x-component of the estimated |
u_comp |
the u-component of the estimated |
value |
estimated values of |
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) mte_vals <- mte_at(u = seq(0.05, 0.95, 0.1), model = mod) if(require("ggplot2")){ ggplot(mte_vals, aes(x = u, y = value)) + geom_line(size = 1) + xlab("Latent Resistance U") + ylab("Estimates of MTE at Mean Values of X") + theme_minimal(base_size = 14) }
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) mte_vals <- mte_at(u = seq(0.05, 0.95, 0.1), model = mod) if(require("ggplot2")){ ggplot(mte_vals, aes(x = u, y = value)) + geom_line(size = 1) + xlab("Latent Resistance U") + ylab("Estimates of MTE at Mean Values of X") + theme_minimal(base_size = 14) }
mte_tilde_at
evaluates marginal treatment effects
projected onto the estimated propensity score. The projection
is done via the function gam
.
mte_tilde_at(p, u, model, ...)
mte_tilde_at(p, u, model, ...)
p |
A numeric vector. Values of the propensity score at which |
u |
A numeric vector. Values of the latent resistance at which |
model |
A fitted MTE model returned by |
... |
Additional parameters passed to |
mte_tilde_at
returns a list of two elements:
df |
A data frame containing five columns:
|
proj |
Fitted |
Zhou, Xiang and Yu Xie. 2019. "Marginal Treatment Effects from A Propensity Score Perspective." Journal of Political Economy, 127(6): 3070-3084.
Zhou, Xiang and Yu Xie. 2020. "Heterogeneous Treatment Effects in the Presence of Self-selection: a Propensity Score Perspective." Sociological Methodology.
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) u <- p <- seq(0.05, 0.95, 0.1) mte_tilde <- mte_tilde_at(p, u, model = mod) # heatmap showing MTE_tilde(p, u) if(require("ggplot2")){ ggplot(mte_tilde$df, aes(x = u, y = p, fill = value)) + geom_tile() + scale_fill_gradient(name = expression(widetilde(MTE)(p, u)), low = "yellow", high = "blue") + xlab("Latent Resistance U") + ylab("Propensity Score p(Z)") + theme_minimal(base_size = 14) } mprte_tilde_df <- subset(mte_tilde$df, p == u) # heatmap showing MPRTE_tilde(p) if(require("ggplot2")){ ggplot(mprte_tilde_df, aes(x = u, y = p, fill = value)) + geom_tile() + scale_fill_gradient(name = expression(widetilde(MPRTE)(p)), low = "yellow", high = "blue") + xlab("Latent Resistance U") + ylab("Propensity Score p(Z)") + theme_minimal(base_size = 14) } # MPRTE_tilde(p) decomposed into the p-component and the u-component if(require(tidyr) && require(dplyr) && require(ggplot2)){ mprte_tilde_df %>% pivot_longer(cols = c(u_comp, p_comp, value)) %>% mutate(name = recode_factor(name, `value` = "MPRTE(p)", `p_comp` = "p(Z) component", `u_comp` = "U component")) %>% ggplot(aes(x = p, y = value)) + geom_line(aes(linetype = name), size = 1) + scale_linetype(name = "") + xlab("Propensity Score p(Z)") + ylab("Treatment Effect") + theme_minimal(base_size = 14) + theme(legend.position = "bottom") }
mod <- mte(selection = d ~ x + z, outcome = y ~ x, data = toydata) u <- p <- seq(0.05, 0.95, 0.1) mte_tilde <- mte_tilde_at(p, u, model = mod) # heatmap showing MTE_tilde(p, u) if(require("ggplot2")){ ggplot(mte_tilde$df, aes(x = u, y = p, fill = value)) + geom_tile() + scale_fill_gradient(name = expression(widetilde(MTE)(p, u)), low = "yellow", high = "blue") + xlab("Latent Resistance U") + ylab("Propensity Score p(Z)") + theme_minimal(base_size = 14) } mprte_tilde_df <- subset(mte_tilde$df, p == u) # heatmap showing MPRTE_tilde(p) if(require("ggplot2")){ ggplot(mprte_tilde_df, aes(x = u, y = p, fill = value)) + geom_tile() + scale_fill_gradient(name = expression(widetilde(MPRTE)(p)), low = "yellow", high = "blue") + xlab("Latent Resistance U") + ylab("Propensity Score p(Z)") + theme_minimal(base_size = 14) } # MPRTE_tilde(p) decomposed into the p-component and the u-component if(require(tidyr) && require(dplyr) && require(ggplot2)){ mprte_tilde_df %>% pivot_longer(cols = c(u_comp, p_comp, value)) %>% mutate(name = recode_factor(name, `value` = "MPRTE(p)", `p_comp` = "p(Z) component", `u_comp` = "U component")) %>% ggplot(aes(x = p, y = value)) + geom_line(aes(linetype = name), size = 1) + scale_linetype(name = "") + xlab("Propensity Score p(Z)") + ylab("Treatment Effect") + theme_minimal(base_size = 14) + theme(legend.position = "bottom") }
A dataset containing 4 columns: y
for a continuous outcome,
d
for a binary treatment, x
for a pretreatment covariate,
and z
for an excluded instrument.
toydata
toydata
An object of class data.frame
with 10000 rows and 4 columns.