Learn R Programming

mosaic (version 0.10.0)

chisq: Extract Chi-squared statistic

Description

Extract Chi-squared statistic

Usage

chisq(x, ...)

## S3 method for class 'htest': chisq(x, ...)

## S3 method for class 'default': chisq(x, ...)

Arguments

x,...
Either an object of class "htest" coming from a Chi-squared test or the inputs to chisq.test.

See Also

stat

Examples

Run this code
if(require(mosaicData)) {
  Mites.table <- tally( ~ outcome + treatment, data=Mites )
  Mites.table
  chisq.test(Mites.table)
  chisq(Mites.table)
  chisq(chisq.test(Mites.table))
  ## Randomization test.  Increase replications to decrease Monte Carlo error.
  do(3) * chisq( tally( ~ outcome + shuffle(treatment),  data=Mites ) )
  Mites.rand <- do(1000) * chisq( tally( ~ outcome + shuffle(treatment),  data=Mites ) )
  tally( ~(X.squared >= chisq(Mites.table)), data=Mites.rand, format="proportion")
}

Run the code above in your browser using DataLab