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 (by default "bca"), also by boostrapping CIs for the NCP and then mapping the result back to Cramer's V.
ci_cramersv(
x,
probs = c(0.025, 0.975),
type = c("chi-squared", "bootstrap"),
boot_type = c("bca", "perc", "norm", "basic"),
R = 9999L,
seed = NULL,
test_adjustment = TRUE,
...
)
An object of class "cint" containing these components:
parameter
: Parameter specification.
interval
: CI for the parameter.
estimate
: Parameter estimate.
probs
: Lower and upper probabilities.
type
: Type of interval.
info
: Additional description.
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 ("bca", "perc", "norm", "basic").
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()
.
A positive lower (1-alpha)*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 = sqrt((ci for NCP + df)/(n (k - 1))), where k is the smaller
number of levels in the two variables (see Smithson p40).
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 ?pchisq
).
Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.
ci_chisq_ncp
.
# 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)
Run the code above in your browser using DataLab