Learn R Programming

sensemakr (version 0.1.2)

add_bound_to_contour: Add bounds to contour plot of omitted variable bias

Description

Convenience function to add bounds on a sensitivity contour plot created with ovb_contour_plot.

Usage

add_bound_to_contour(...)

# S3 method for lm add_bound_to_contour(model, treatment, benchmark_covariates, kd = 1, ky = kd, reduce = TRUE, sensitivity.of = c("estimate", "t-value"), label.text = TRUE, cex.label.text = 1, label.bump.x = 0.02, label.bump.y = 0.02, round = 2, ...)

# S3 method for numeric add_bound_to_contour(r2dz.x, r2yz.dx, bound_value = NULL, bound_label = NULL, label.text = TRUE, cex.label.text = 1, label.bump.x = 0.02, label.bump.y = 0.02, round = 2, ...)

Arguments

...

arguments passed to other methods.

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.

reduce

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

sensitivity.of

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

label.text

should label texts be plotted? Default is TRUE.

cex.label.text

size of the label text.

label.bump.x

bump on the x coordinate of label text.

label.bump.y

bump on the y coordinate of label text.

round

integer indicating the number of decimal places to be used for rounding.

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_value

value to be printed in label bound.

bound_label

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

Value

The function adds bounds in an existing contour plot and returns `NULL`.

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

# add bound 3/1 times stronger than female
add_bound_to_contour(model,
                     treatment = "directlyharmed",
                     benchmark_covariates = "female",
                     kd = 3, ky = 1)

# add bound 50/2 times stronger than age
add_bound_to_contour(model,
                     treatment = "directlyharmed",
                     benchmark_covariates = "age",
                     kd = 50, ky = 2)

# }

Run the code above in your browser using DataLab