ovb_extreme_plot: Extreme scenarios plots of omitted variable bias

Description Usage Arguments Value References Examples

View source: R/ovb_plots.R

Description

Extreme scenario plots of omitted variable bias for sensitivity analysis. The main inputs are an lm model, the treatment variable and the covariates used for benchmarking the strength of unobserved confounding.

The horizontal axis shows the partial R2 of the unobserved confounder(s) with the treatment. The vertical axis shows the adjusted treatment effect estimate. The partial R2 of the confounder with the outcome is represented by different curves for each scenario, as given by the parameter r2yz.dx. The red marks on horizontal axis are bounds on the partial R2 of the unobserved confounder kd times as strong as the covariates used for benchmarking. The dotted red line represent the threshold for the effect estimate deemed to be problematic (for instance, zero).

See Cinelli and Hazlett (2020) for details.

Usage

 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ovb_extreme_plot(...)

## S3 method for class 'lm'
ovb_extreme_plot(
  model,
  treatment,
  benchmark_covariates = NULL,
  kd = 1,
  r2yz.dx = c(1, 0.75, 0.5),
  r2dz.x = NULL,
  reduce = TRUE,
  threshold = 0,
  lim = min(c(r2dz.x + 0.1, 0.5)),
  legend = TRUE,
  cex.legend = 0.65,
  legend.bty = "n",
  ...
)

## S3 method for class 'formula'
ovb_extreme_plot(
  formula,
  data,
  treatment,
  benchmark_covariates = NULL,
  kd = 1,
  r2yz.dx = c(1, 0.75, 0.5),
  r2dz.x = NULL,
  reduce = TRUE,
  threshold = 0,
  lim = min(c(r2dz.x + 0.1, 0.5)),
  legend = TRUE,
  cex.legend = 0.65,
  legend.bty = "n",
  ...
)

## S3 method for class 'numeric'
ovb_extreme_plot(
  estimate,
  se,
  dof,
  r2dz.x = NULL,
  r2yz.dx = c(1, 0.75, 0.5),
  reduce = TRUE,
  threshold = 0,
  lim = min(c(r2dz.x + 0.1, 0.5)),
  legend = TRUE,
  legend.title = NULL,
  cex.legend = 0.65,
  legend.bty = "n",
  xlab = NULL,
  ylab = NULL,
  cex.lab = 0.7,
  cex.axis = 0.7,
  list.par = list(oma = c(1, 1, 1, 1)),
  ...
)

Arguments

...

arguments passed to other methods. First argument should either be an lm model with the outcome regression, a formula describing the model along with the data.frame containing the variables of the model, or a numeric vector with the coefficient estimate.

model

An lm object with the outcome regression.

treatment

A character vector with the name of the treatment variable of the model.

benchmark_covariates

The user has two options: (i) character vector of the names of covariates that will be used to bound the plausible strength of the unobserved confounders. Each variable will be considered separately; (ii) a named list with character vector names of covariates that will be used, as a group, to bound the plausible strength of the unobserved confounders. The names of the list will be used for the benchmark labels. Note: for factor variables with more than two levels, you need to provide the name of each level as encoded in the lm model (the columns of model.matrix).

kd

numeric vector. Parameterizes how many times stronger the confounder is related to the treatment in comparison to the observed benchmark covariate. Default value is 1 (confounder is as strong as benchmark covariate).

r2yz.dx

Hypothetical partial R2 of unobserved confounder Z with outcome Y, given covariates X and treatment D.

r2dz.x

Hypothetical partial R2 of unobserved confounder Z with treatment D, given covariates X.

reduce

Should the bias adjustment reduce or increase the absolute value of the estimated coefficient? Default is TRUE.

threshold

estimate threshold.

lim

sets limit for x-axis. If 'NULL', limits are computed automatically.

legend

should legend be plotted? Default is TRUE.

cex.legend

size of the text for the legend.

legend.bty

legend box. See bty argument of par.

formula

an object of the class formula: a symbolic description of the model to be fitted.

data

data needed only when you pass a formula as first parameter. An object of the class data.frame containing the variables used in the analysis.

estimate

Coefficient estimate.

se

Standard error of the coefficient estimate.

dof

Residual degrees of freedom of the regression.

legend.title

the legend title. If NULL, then default legend is used.

xlab

label of x axis. If 'NULL', default label is used.

ylab

label of y axis. If 'NULL', default label is used.

cex.lab

The magnification to be used for x and y labels relative to the current setting of cex.

cex.axis

The magnification to be used for axis annotation relative to the current setting of cex.

list.par

arguments to be passed to par. It needs to be a named list.

Value

The function returns invisibly the data used for the extreme plot.

References

Cinelli, C. and Hazlett, C. (2020), "Making Sense of Sensitivity: Extending Omitted Variable Bias." Journal of the Royal Statistical Society, Series B (Statistical Methodology).

Examples

1
2
3
4
5
6
7
8
9
# runs regression model
model <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar +
                         pastvoted + hhsize_darfur + female + village,
                         data = darfur)
# extreme scenarios plot
ovb_extreme_plot(model, treatment = "directlyharmed",
                        benchmark_covariates = "female",
                        kd = 1:2,
                        lim = 0.05)

sensemakr documentation built on Oct. 8, 2021, 9:10 a.m.