prop_strat_wilson()
R/estimate_proportion.R
update_weights_strat_wilson.Rd
This function wraps the iteration procedure that allows you to estimate the weights for each proportional strata. This assumes to minimize the weighted squared length of the confidence interval.
update_weights_strat_wilson(
vars,
strata_qnorm,
initial_weights,
n_per_strata,
max_iterations = 50,
conf_level = 0.95,
tol = 0.001
)
(numeric
)
normalized proportions for each strata.
(numeric(1)
)
initial estimation with identical weights of the quantiles.
(numeric
)
initial weights used to calculate strata_qnorm
. This can
be optimized in the future if we need to estimate better initial weights.
(numeric
)
number of elements in each strata.
(integer(1)
)
maximum number of iterations to be tried. Convergence is always checked.
(proportion
)
confidence level of the interval.
(numeric(1)
)
tolerance threshold for convergence.
A list
of 3 elements: n_it
, weights
, and diff_v
.
For references and details see prop_strat_wilson()
.
vs <- c(0.011, 0.013, 0.012, 0.014, 0.017, 0.018)
sq <- 0.674
ws <- rep(1 / length(vs), length(vs))
ns <- c(22, 18, 17, 17, 14, 12)
update_weights_strat_wilson(vs, sq, ws, ns, 100, 0.95, 0.001)
#> $n_it
#> [1] 3
#>
#> $weights
#> [1] 0.2067191 0.1757727 0.1896962 0.1636346 0.1357615 0.1284160
#>
#> $diff_v
#> [1] 1.458717e-01 1.497223e-03 1.442189e-06
#>