Learn R Programming

sensemakr (version 0.1.2)

sensemakr: Sensitivity analysis to unobserved confounders

Description

This function performs sensitivity analysis to omitted variables as discussed in Cinelli and Hazlett (2018). It returns an object of class sensemakr with several pre-computed sensitivity statistics for reporting. After running sensemakr you may directly use the plot, print and summary methods in the returned object.

Usage

sensemakr(...)

# S3 method for lm sensemakr(model, treatment, benchmark_covariates = NULL, kd = 1, ky = kd, q = 1, alpha = 0.05, r2dz.x = NULL, r2yz.dx = r2dz.x, bound_label = "", reduce = TRUE, ...)

# S3 method for formula sensemakr(formula, data, treatment, benchmark_covariates = NULL, kd = 1, ky = kd, q = 1, alpha = 0.05, r2dz.x = NULL, r2yz.dx = r2dz.x, bound_label = "", reduce = TRUE, ...)

Arguments

...

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

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.

q

percent change of the effect estimate that would be deemed problematic. Default is 1, which means a reduction of 100% of the current effect estimate (bring estimate to zero). It has to be greater than zero.

alpha

significance level used for computation of the robustness value. If NULL (the default), the robustness value refers only to the point estimate, no sampling uncertainty is taken into account.

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.

reduce

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

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.

Value

An object of class sensemakr, containing:

info

A data.frame with the general information of the analysis, including the formula used, the name of the treatment variable, parameter values such as q, alpha, and whether the bias is assumed to reduce the current estimate.

sensitivity_stats

A data.frame with the sensitivity statistics for the treatment variable, as computed by the function sensitivity_stats.

bounds

A data.frame with bounds on the strength of confounding according to some benchmark covariates, as computed by the function ovb_bounds.

References

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

See Also

The function sensemakr is a convenience function. You may use the other sensitivity functions of the package directly, such as the functions for sensitivity plots (ovb_contour_plot, ovb_extreme_plot) the functions for computing bias-adjusted estimates and t-values (adjusted_estimate, adjusted_t), the functions for computing the robustness value and partial R2 (robustness_value, partial_r2), or the functions for bounding the strength of unobserved confounders (ovb_bounds), among others.

Examples

Run this code
# NOT RUN {
# loads dataset
data("darfur")

# runs regression model
model <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar +
                         pastvoted + hhsize_darfur + female + village, data = darfur)

# runs sensemakr for sensitivity analysis
sensitivity <- sensemakr(model, treatment = "directlyharmed",
                               benchmark_covariates = "female",
                               kd = 1:3)
# short description of results
sensitivity

# long description of results
summary(sensitivity)

# plot bias contour of point estimate
plot(sensitivity)

# plot bias contour of t-value
plot(sensitivity, sensitivity.of = "t-value")

# plot extreme scenario
plot(sensitivity, type = "extreme")

# latex code for sensitivity table
ovb_minimal_reporting(sensitivity)

# }

Run the code above in your browser using DataLab