The sensemakr package implements a suite of sensitivity analysis tools that makes it easier to understand the impact of omitted variables in linear regression models, as discussed in Cinelli and Hazlett (2020).
package
Details
The main function of the package is sensemakr, which computes the most common sensitivity analysis results. After running sensemakr you may directly use the plot and print methods in the returned object.
You may also 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.
More information can be found on the help documentation, vignettes and related papers.
Examples
# loads datasetdata("darfur")# runs regression modelmodel <- lm(peacefactor ~ directlyharmed + age + farmer_dar + herder_dar + pastvoted + hhsize_darfur + female + village, data = darfur)# runs sensemakr for sensitivity analysissensitivity <- sensemakr(model, treatment ="directlyharmed", benchmark_covariates ="female", kd =1:3)# short description of resultssensitivity
# long description of resultssummary(sensitivity)# plot bias contour of point estimateplot(sensitivity)# plot bias contour of t-valueplot(sensitivity, sensitivity.of ="t-value")# plot extreme scenarioplot(sensitivity, type ="extreme")# latex code for sensitivity tableovb_minimal_reporting(sensitivity)# data.frame with sensitivity statisticssensitivity$sensitivity_stats
# data.frame with bounds on the strengh of confounderssensitivity$bounds
### Using sensitivity functions directly #### robustness value of directly harmed q = 1 (reduce estimate to zero)robustness_value(model, covariates ="directlyharmed")# robustness value of directly harmed q = 1/2 (reduce estimate in half)robustness_value(model, covariates ="directlyharmed", q =1/2)# robustness value of directly harmed q = 1/2, alpha = 0.05robustness_value(model, covariates ="directlyharmed", q =1/2, alpha =0.05)# partial R2 of directly harmed with peacefactorpartial_r2(model, covariates ="directlyharmed")# partial R2 of female with peacefactorpartial_r2(model, covariates ="female")# data.frame with sensitivity statisticssensitivity_stats(model, treatment ="directlyharmed")# bounds on the strength of confounders using female and ageovb_bounds(model, treatment ="directlyharmed", benchmark_covariates = c("female","age"), kd =1:3)# adjusted estimate given hypothetical strength of confounderadjusted_estimate(model, treatment ="directlyharmed", r2dz.x =0.1, r2yz.dx =0.1)# adjusted t-value given hypothetical strength of confounderadjusted_t(model, treatment ="directlyharmed", r2dz.x =0.1, r2yz.dx =0.1)# bias contour plot directly from lm modelovb_contour_plot(model, treatment ="directlyharmed", benchmark_covariates ="female", kd =1:3)# extreme scenario plot directly from lm modelovb_extreme_plot(model, treatment ="directlyharmed", benchmark_covariates ="female", kd =1:3, lim =0.05)
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).