Computes the effective sample size using either the Kish formula or the perplexity (entropy-based) method.
Usage
calc_model_ess(w, method = c("kish", "perplexity"), na_rm = TRUE)Details
Two methods are available:
Kish method (method = "kish"):
Uses the standard Kish ESS formula: \(\mathrm{ESS} = (\sum w)^2 / \sum w^2\).
This provides a measure of how much information is retained when using weighted
samples compared to an unweighted sample of the same size.
Perplexity method (method = "perplexity"):
Uses the exponential of the entropy: \(\mathrm{ESS} = \exp(-\sum w_i \log w_i)\),
where weights are first normalized to sum to 1. This measures the effective number
of models based on the entropy of the weight distribution. Also known as the
perplexity or exponential entropy.
Both methods yield values between 1 (all weight on one model) and \(n\) (uniform weights), but they measure slightly different aspects of weight concentration. The Kish formula is more commonly used in survey sampling, while perplexity is common in information theory and model averaging.
See also
Other calibration-metrics:
calc_convergence_diagnostics(),
calc_model_agreement_index(),
calc_model_cvw()
Examples
# Uniform weights
w_uniform <- rep(1/10, 10)
calc_model_ess(w_uniform, method = "kish") # 10
#> [1] 10
calc_model_ess(w_uniform, method = "perplexity") # 10
#> [1] 10
# Concentrated weights
w_conc <- c(0.9, rep(0.01, 10))
calc_model_ess(w_conc, method = "kish") # ~1.2
#> [1] 1.233046
calc_model_ess(w_conc, method = "perplexity") # ~1.74
#> [1] 1.742536
