View source: R/chisq_test_simulate.R
| chisq.test.simulate | R Documentation |
chisq.test.simulate simulates the chi-squared test for a 2-way contingency tabel.
chisq.test.simulate(x, conditioning = "total", x0 = NULL, B = 10000)
x |
matrix with the contingency table |
conditioning |
character string specifying the simulation scenario. Defaults to |
x0 |
matrix specifying the null distribution. Defaults to |
B |
integer specifying the number of replicates used in the Monte Carlo test. Defaults to 10000. |
Using conditioning="both" corresponds to selecting simulate.p.value=TRUE in chisq.test. However, conditioning on both row and column marginals appears to be rarely justified in real data. Instead conditioning="total" is the correct choice for testing independence. Similarly, conditioning="row" is recommended when the row marginals e.g. are fixed by experimental design.
The option x0 has no effect when conditioning on both row and column marginals.
An object of class "htest".
The code has not been optimized for speed, and might be slow.
Bo Markussen
chisq.test
# The Avadex dataset
Xobs <- matrix(c(2,3,6,40),2,2)
rownames(Xobs) <- c("Avadex +","Avadex -")
colnames(Xobs) <- c("Tumor +","Tumor -")
# In this example only the rows appear to be fixed by experimental design.
# As is seen below, conditioning also on the columns is misleading conservative.
chisq.test.simulate(Xobs,"both")
chisq.test.simulate(Xobs,"row")
chisq.test.simulate(Xobs,"total")
# Conditioning both on row and column marginals is simular to chisq.test().
chisq.test(Xobs,simulate.p.value=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.