Learn R Programming

confintr (version 1.0.0)

ci_chisq_ncp: CI for the NCP of the Chi-Squared Distribution

Description

This function calculates CIs for the non-centrality parameter (NCP) of the chi-squared distribution. A positive lower (1-alpha)*100%-confidence limit for the NCP goes hand-in-hand with a significant association test at level alpha. By default, CIs are computed by Chi-squared test inversion. This can be unreliable for very large test statistics. The default bootstrap type is "bca".

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 = 9999L,
  seed = NULL,
  ...
)

Value

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.

Arguments

x

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

probs

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

correct

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

type

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

boot_type

Type of bootstrap CI ("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().

References

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

See Also

ci_cramersv.

Examples

Run this code
ci_chisq_ncp(mtcars[c("am", "vs")])
ci_chisq_ncp(mtcars[c("am", "vs")], type = "bootstrap", R = 999)  # Use larger R

Run the code above in your browser using DataLab