| run_sensemakr | R Documentation |
Performs the Cinelli & Hazlett style sensitivity analysis using sensemakr for two linear models:
I ~ trans_FC + t_norm + PopDensity + War
C ~ trans_FC + t_norm + PopDensity + War
treating trans_FC as the exposure of interest and using
PopDensity and War as benchmark covariates.
run_sensemakr(DT, dir_csv = NULL)
DT |
A |
dir_csv |
Character scalar or |
This function requires the sensemakr package (listed under
Suggests); an informative error is raised at call time if it is
not installed.
For each outcome (I and C), an OLS model is estimated and
passed to sensemakr::sensemakr() with:
treatment = "trans_FC"
benchmark_covariates = c("PopDensity", "War")
The resulting sensemakr objects are summarized via
summary(), converted to data frames, and written to CSV files:
"sensemakr_I_FC.csv" for outcome I.
"sensemakr_C_FC.csv" for outcome C.
These files are written only when dir_csv is supplied.
A list with components:
I: the sensemakr object for the model with
outcome I.
C: the sensemakr object for the model with
outcome C.
# This example runs only when 'sensemakr' is installed.
if (requireNamespace("sensemakr", quietly = TRUE)) {
DT <- data.frame(
I = rpois(30, lambda = 5),
C = rpois(30, lambda = 3),
trans_FC = sample(0:1, 30, replace = TRUE),
t_norm = rnorm(30),
PopDensity = rnorm(30),
War = sample(0:1, 30, replace = TRUE)
)
res_sense <- run_sensemakr(DT)
if (!is.null(res_sense$I)) {
print(summary(res_sense$I))
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.