plot.sens: Plot Method for 'sens' Objects

Description Usage Arguments Value Examples

View source: R/plot.sens.R

Description

Contour plot for sensitivity analysis objects.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'sens'
plot(
  x,
  outcome_name = "Outcome",
  x_axis = c("eta_k", "gamma_k"),
  other = list(`eta_k-1` = NULL, `gamma_k-1` = NULL),
  ...
)

Arguments

x

an object of class sens returned by the sens function

outcome_name

a character string indicating the name of the outcome.

x_axis

sensitivity analysis parameter shown on the x axis. Default is "eta_k", i.e., the difference in the prevalence of an unobserved confounder U between treated and untreated units given pretreatment covariates X and mediators M_1,…, M_k. Alternatively, it can be "gamma_k", i.e., the average effect of the unobserved confounder U on the outcome given pretreatment covariates X, treatment A, and mediators M_1,…, M_k.

other

a named list indicating the values at which other sensitivity analysis parameters, namely, `eta_k-1` and `gamma_k-1`, are held. This is needed only when the bias formula involves η_{k-1} and γ_{k-1} as well as η_k and γ_k. The default is to set both η_{k-1} and γ_{k-1} at their average values in the sens object.

...

additional arguments

Value

a ggplot2 plot, which can be further customized by the user.

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
data(tatar)

m1 <- c("trust_g1", "victim_g1", "fear_g1")
m2 <- c("trust_g2", "victim_g2", "fear_g2")
m3 <- c("trust_g3", "victim_g3", "fear_g3")
mediators <- list(m1, m2, m3)

formula_m0 <- annex ~ kulak + prosoviet_pre + religiosity_pre + land_pre +
  orchard_pre + animals_pre + carriage_pre + otherprop_pre + violence
formula_m1 <- update(formula_m0,    ~ . + trust_g1 + victim_g1 + fear_g1)
formula_m2 <- update(formula_m1,    ~ . + trust_g2 + victim_g2 + fear_g2)
formula_m3 <- update(formula_m2,    ~ . + trust_g3 + victim_g3 + fear_g3)
formula_ps <- violence ~ kulak + prosoviet_pre + religiosity_pre +
  land_pre + orchard_pre + animals_pre + carriage_pre + otherprop_pre

####################################################
# Causal Paths Analysis using GLM
####################################################

# outcome models
glm_m0 <- glm(formula_m0, family = binomial("logit"), data = tatar)
glm_m1 <- glm(formula_m1, family = binomial("logit"), data = tatar)
glm_m2 <- glm(formula_m2, family = binomial("logit"), data = tatar)
glm_m3 <- glm(formula_m3, family = binomial("logit"), data = tatar)
glm_ymodels <- list(glm_m0, glm_m1, glm_m2, glm_m3)

# propensity score model
glm_ps <- glm(formula_ps, family = binomial("logit"), data = tatar)

# causal paths analysis using glm
# note: For illustration purposes only a small number of bootstrap replicates are used
paths_glm <- paths(a = "violence", y = "annex", m = mediators,
  glm_ymodels, ps_model = glm_ps, data = tatar, nboot = 3)

# sensitivity analysis for the path-specific effect via M1
sens_glm <- sens(paths_glm, confounded = "M1", estimand = "via M1",
  gamma_values = - seq(0, 0.5, 0.005), eta_values = seq(-0.5, 0.5, 0.005))

plot(sens_glm)

paths documentation built on June 18, 2021, 9:07 a.m.