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.

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,
  ...
)

Arguments

x

The result of stats::chisq.test(), a matrix/table of counts, or a data.frame with exactly two columns representing the two variables.

probs

Lower and upper probabilities, by default c(0.025, 0.975).

type

Type of CI. One of "chi-squared" (default) or "bootstrap".

boot_type

Type of bootstrap CI. Only used for type = "bootstrap".

R

The number of bootstrap resamples. Only used for type = "bootstrap".

seed

An integer random seed. Only used for type = "bootstrap".

test_adjustment

Adjustment to allow for test of association, see Details. The default is TRUE.

...

Further arguments passed to boot::boot().

Value

An object of class "cint", see ci_mean() for details.

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().

References

Smithson, M. (2003). Confidence intervals. Series: Quantitative Applications in the Social Sciences. New York, NY: Sage Publications.

Examples

# 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 
#>