ci_chisq_ncp {confintr}R Documentation

Confidence Interval for the Non-Centrality Parameter of the Chi-Squared Distribution

Description

This function calculates confidence intervals for the non-centrality parameter of the chi-squared distribution based on chi-squared test inversion or the bootstrap. A positive lower (1-alpha)*100%-confidence limit for the ncp goes hand-in-hand with a significant association test at level alpha.

Usage

ci_chisq_ncp(
  x,
  probs = c(0.025, 0.975),
  correct = TRUE,
  type = c("chi-squared", "bootstrap"),
  boot_type = c("bca", "perc", "norm", "basic"),
  R = 9999,
  seed = NULL,
  ...
)

Arguments

x

The result of stats::chisq.test, a table/matrix of frequencies, or a data.frame with exactly two columns.

probs

Error probabilites. The default c(0.025, 0.975) gives a symmetric 95% confidence interval.

correct

Should Yates continuity correction be applied to the 2x2 case? The default is TRUE (also used in the bootstrap).

type

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

boot_type

Type of bootstrap confidence interval ("bca", "perc", "norm", "basic"). 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".

...

Further arguments passed to boot::boot.

Details

Bootstrap confidence intervals are calculated by the package "boot", see references. The default bootstrap type is "bca" (bias-corrected accelerated) as it enjoys the property of being second order accurate as well as transformation respecting (see Efron, p. 188). Note that large chi-squared test statistics might provide unreliable results with method "chi-squared" (see ?pchisq).

Value

A list with class cint containing these components:

References

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

  2. Efron, B. and Tibshirani R. J. (1994). An Introduction to the Bootstrap. Chapman & Hall/CRC.

  3. Canty, A and Ripley B. (2019). boot: Bootstrap R (S-Plus) Functions.

See Also

ci_cramersv.

Examples

ci_chisq_ncp(mtcars[c("am", "vs")])
ci_chisq_ncp(mtcars[c("am", "vs")], type = "bootstrap", R = 999)
ir <- iris
ir$PL <- ir$Petal.Width > 1
ci_chisq_ncp(ir[, c("Species", "PL")])
ci_chisq_ncp(ir[, c("Species", "PL")], probs = c(0.05, 1))

[Package confintr version 0.1.1 Index]