Sensitivity Summary (for survey weights)
summarize_sensitivity_survey.Rd
Returns a data.frame or Kable table with summary measures of sensitivity; helper function for main summary function, and allows users to directly input a survey object and a design object
Examples
data(poll.data)
poll_srs <- survey::svydesign(ids = ~ 1, data = poll.data)
#> Warning: No weights or probabilities supplied, assuming equal probability
pop_targets = c(1, 0.212, 0.264, 0.236, 0.310,
0.114, 0.360, 0.528, 0.114,
0.021, 0.034, 0.805,
0.266, 0.075, 0.312, 0.349)
names(pop_targets) = c("(Intercept)",
"age_buckets36to50",
"age_buckets51to64",
"age_bucketsOver65",
"educHigh School or Less",
"educPost-grad",
"educSome college",
"genderWomen",
"raceBlack",
"raceHispanic",
"raceOther",
"raceWhite",
"pidIndependent", "pidOther",
"pidRepublican", "bornagainYes")
#Set up raking formula:
formula_rake <- ~ age_buckets + educ + gender + race + pid + bornagain
#PERFORM RAKING:
model_rake <- survey::calibrate(
design = poll_srs,
formula = formula_rake,
population = pop_targets,
calfun = "raking",
force = TRUE
)
rake_results <- survey::svydesign( ~ 1, data = poll.data, weights = stats::weights(model_rake))
#Estimate from raking results:
weights = stats::weights(rake_results) * nrow(model_rake)
unweighted_estimate = survey::svymean(~ Y, poll_srs, na.rm = TRUE)
weighted_estimate = survey::svymean(~ Y, model_rake, na.rm = TRUE)
summarize_sensitivity(estimand = 'Survey',
Y = poll.data$Y,
weights = weights,
svy_srs = unweighted_estimate,
svy_wt = weighted_estimate,
b_star = 0.5)
#> Unweighted Unweighted_SE Estimate SE RV
#> 1 0.54 0.0157686 0.4684269 0.0167966 0.04977723