Learn R Programming

sensemakr (version 0.1.2)

ovb_contour_plot: Contour plots of omitted variable bias

Description

Contour 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 of the plot shows hypothetical values of the partial R2 of the unobserved confounder(s) with the treatment. The vertical axis shows hypothetical values of the partial R2 of the unobserved confounder(s) with the outcome. The contour levels represent the adjusted estimates (or t-values) of the treatment effect. The reference points are the bounds on the partial R2 of the unobserved confounder if it were k times ``as strong'' as the observed covariate used for benchmarking (see arguments kd and ky). The dotted red line show the chosen critical threshold (for instance, zero): confounders with such strength (or stronger) are sufficient to invalidate the research conclusions. All results are exact for single confounders and conservative for multiple/nonlinear confounders.

See Cinelli and Hazlett (2018) for details.

Usage

ovb_contour_plot(...)

# S3 method for lm ovb_contour_plot(model, treatment, benchmark_covariates = NULL, kd = 1, ky = kd, r2dz.x = NULL, r2yz.dx = r2dz.x, bound_label = NULL, sensitivity.of = c("estimate", "t-value"), reduce = TRUE, estimate.threshold = 0, t.threshold = 2, lim = max(c(0.4, r2dz.x, r2yz.dx)), nlevels = 20, col.contour = "grey40", col.thr.line = "red", label.text = TRUE, label.bump.x = 0.02, label.bump.y = 0.02, ...)

# S3 method for formula ovb_contour_plot(formula, data, treatment, benchmark_covariates = NULL, kd = 1, ky = kd, r2dz.x = NULL, r2yz.dx = r2dz.x, bound_label = NULL, sensitivity.of = c("estimate", "t-value"), reduce = TRUE, estimate.threshold = 0, t.threshold = 2, lim = max(c(0.4, r2dz.x, r2yz.dx)), nlevels = 20, col.contour = "grey40", col.thr.line = "red", label.text = TRUE, ...)

# S3 method for numeric ovb_contour_plot(estimate, se, dof, r2dz.x = NULL, r2yz.dx = r2dz.x, bound_label = "", sensitivity.of = c("estimate", "t-value"), reduce = TRUE, estimate.threshold = 0, t.threshold = 2, lim = max(c(0.4, r2dz.x + 0.1, r2yz.dx + 0.1)), nlevels = 20, col.contour = "black", col.thr.line = "red", label.text = TRUE, cex.label.text = 1, label.bump.x = 0.02, label.bump.y = 0.02, ...)

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

a character vector of the names of covariates that will be used to bound the plausible strength of the unobserved confounders.

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).

ky

numeric vector. Parameterizes how many times stronger the confounder is related to the outcome in comparison to the observed benchmark covariate. Default value is the same as kd.

r2dz.x

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

r2yz.dx

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

bound_label

label to bounds provided manually in r2dz.x and r2yz.dx.

sensitivity.of

should the contour plot show adjusted estimates ("estimate") or adjusted t-values ("t-value")?

reduce

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

estimate.threshold

critical threshold for the point estimate.

t.threshold

critical threshold for the t-value.

lim

sets limit of the plot.

nlevels

number of levels for the contour plot.

col.contour

color of contour lines.

col.thr.line

color of threshold contour line.

label.text

should label texts be plotted? Default is TRUE.

label.bump.x

bump on the x coordinate of label text.

label.bump.y

bump on the y coordinate of label text.

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.

cex.label.text

size of the label text.

Value

The function returns invisibly the data used for the contour plot (contour grid and bounds).

References

Cinelli, C. and Hazlett, C. "Making Sense of Sensitivity: Extending Omitted Variable Bias." (2018).

Examples

Run this code
# NOT RUN {
# runs regression model
model <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar +
                         pastvoted + hhsize_darfur + female + village,
                         data = darfur)
# contour plot
ovb_contour_plot(model, treatment = "directlyharmed",
                        benchmark_covariates = "female",
                        kd = 1:2)

# }

Run the code above in your browser using DataLab