mte_tilde_at: Evaluate Marginal Treatment Effects Projected onto the...

Description Usage Arguments Value References Examples

View source: R/mte_tilde_at.R

Description

mte_tilde_at evaluates marginal treatment effects projected onto the estimated propensity score. The projection is done via the function gam.

Usage

1
mte_tilde_at(p, u, model, ...)

Arguments

p

A numeric vector. Values of the propensity score at which \widetilde{\textup{MTE}}(p, u) is evaluated.

u

A numeric vector. Values of the latent resistance at which \widetilde{\textup{MTE}}(p, u) is evaluated.

model

A fitted MTE model returned by mte.

...

Additional parameters passed to gam.

Value

mte_tilde_at returns a list of two elements:

df

A data frame containing five columns:

  • p input values of p.

  • u input values of u.

  • p_comp the p-component of the estimated \widetilde{\textup{MTE}}(p, u)

  • u_comp the u-component of the estimated \widetilde{\textup{MTE}}(p, u)

  • value estimated values of \widetilde{\textup{MTE}}(p, u)

proj

Fitted gam model for E[μ_1(X)-μ_0(X)|P(Z)=p]

References

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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")
}

xiangzhou09/localIV documentation built on June 28, 2020, 1:38 a.m.