dot-strata_normal_quantile: Helper Function for the Estimation of Stratified Quantiles

.strata_normal_quantileR Documentation

Helper Function for the Estimation of Stratified Quantiles

Description

This function wraps the estimation of stratified percentiles when we assume the approximation for large numbers. This is necessary only in the case proportions for each strata are unequal.

Usage

.strata_normal_quantile(vars, weights, conf.level)

Arguments

weights

(numeric or NULL)
weights for each level of the strata. If NULL, they are estimated using the iterative algorithm that minimizes the weighted squared length of the confidence interval.

conf.level

(numeric)
a scalar in ⁠(0, 1)⁠ indicating the confidence level. Default is 0.95

Value

Stratified quantile.

See Also

proportion_ci_strat_wilson()

Examples

strata_data <- table(data.frame(
  "f1" = sample(c(TRUE, FALSE), 100, TRUE),
  "f2" = sample(c("x", "y", "z"), 100, TRUE),
  stringsAsFactors = TRUE
))
ns <- colSums(strata_data)
ests <- strata_data["TRUE", ] / ns
vars <- ests * (1 - ests) / ns
weights <- rep(1 / length(ns), length(ns))

cardx:::.strata_normal_quantile(vars, weights, 0.95)

cardx documentation built on Sept. 11, 2024, 9:12 p.m.