Extract Chi-squared statistic
chisq(x, ...)
# S3 method for htest
chisq(x, ...)
# S3 method for table
chisq(x, correct = FALSE, ...)
# S3 method for default
chisq(x, correct = FALSE, ...)
An object of class "htest"
a coming from a Chi-squared test,
an object of class "table"
, or
the inputs to tally()
.
additional arguments passed on to tally
or chisq.test
.
a logical indicating whether a continuity correction should be applied.
after_stat()
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")
}
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> Using parallel package.
#> * Set seed with set.rseed().
#> * Disable this message with options(`mosaic:parallelMessage` = FALSE)
#> (X.squared >= chisq(Mites.table))
#> TRUE FALSE
#> 0.022 0.978