This function calculates CIs for the population Cramer's V. By default, a parametric approach based on the non-centrality parameter (NCP) of the chi-squared distribution is utilized. Alternatively, bootstrap CIs are available (default "bca"), also by boostrapping CIs for the NCP and then mapping the result back to Cramer's V.
The result of stats::chisq.test()
, a matrix/table of counts, or
a data.frame
with exactly two columns representing the two variables.
Lower and upper probabilities, by default c(0.025, 0.975)
.
Type of CI. One of "chi-squared" (default) or "bootstrap".
Type of bootstrap CI. Only used for type = "bootstrap"
.
The number of bootstrap resamples. Only used for type = "bootstrap"
.
An integer random seed. Only used for type = "bootstrap"
.
Adjustment to allow for test of association, see Details.
The default is TRUE
.
Further arguments passed to boot::boot()
.
An object of class "cint", see ci_mean()
for details.
A positive lower \((1 - \alpha) \cdot 100\%\)-confidence limit for the NCP goes
hand-in-hand with a significant association test at level \(\alpha\). In order to
allow such test approach also with Cramer's V, if the lower bound for the NCP is 0,
we round down to 0 the lower bound for Cramer's V as well.
Without this slightly conservative adjustment, the lower limit for V would always be
positive since the CI for V is found by
\(\sqrt{(\textrm{CI for NCP} + \textrm{df})/(n \cdot (k - 1))}\), where \(k\) is the
smaller number of levels in the two variables (see Smithson, p.40).
Use test_adjustment = FALSE
to switch off this behaviour. Note that this is
also a reason to bootstrap V via NCP instead of directly bootstrapping V.
Further note that no continuity correction is applied for 2x2 tables,
and that large chi-squared test statistics might provide unreliable results with
method "chi-squared", see stats::pchisq()
.
Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.
# Example from Smithson, M., page 41
test_scores <- as.table(
rbind(
Private = c(6, 14, 17, 9),
Public = c(30, 32, 17, 3)
)
)
suppressWarnings(X2 <- stats::chisq.test(test_scores))
ci_cramersv(X2)
#>
#> Two-sided 95% chi-squared confidence interval for the population
#> Cramer's V
#>
#> Sample estimate: 0.3674853
#> Confidence interval:
#> 2.5% 97.5%
#> 0.2233351 0.5448121
#>