rsp <- c(
TRUE, TRUE, TRUE, TRUE, TRUE,
FALSE, FALSE, FALSE, FALSE, FALSE
)
prop_wilson(rsp, conf_level = 0.9)
# Stratified Wilson confidence interval with unequal probabilities
set.seed(1)
rsp <- sample(c(TRUE, FALSE), 100, TRUE)
strata_data <- data.frame(
"f1" = sample(c("a", "b"), 100, TRUE),
"f2" = sample(c("x", "y", "z"), 100, TRUE),
stringsAsFactors = TRUE
)
strata <- interaction(strata_data)
n_strata <- ncol(table(rsp, strata)) # Number of strata
prop_strat_wilson(
rsp = rsp, strata = strata,
conf_level = 0.90
)
# Not automatic setting of weights
prop_strat_wilson(
rsp = rsp, strata = strata,
weights = rep(1 / n_strata, n_strata),
conf_level = 0.90
)
prop_clopper_pearson(rsp, conf_level = .95)
prop_wald(rsp, conf_level = 0.95)
prop_wald(rsp, conf_level = 0.95, correct = TRUE)
prop_agresti_coull(rsp, conf_level = 0.95)
prop_jeffreys(rsp, conf_level = 0.95)
Run the code above in your browser using DataLab