View source: R/power_chisq_test_simulate.R
power.chisq.test.simulate | R Documentation |
power.chisq.test.simulate
simulates power for tests for 2-way contingency tables based on the Pearson Chi-squared test statistics by simulation under 4 different conditioning scenarios.
power.chisq.test.simulate( x, conditioning = "total", x0 = NULL, sig.level = 0.05, B = 10000 )
x |
matrix specifying the alternative distribution of the contingency table. |
conditioning |
character string specifying the simulation scenario. Defaults to |
x0 |
matrix specifying the null distribution. Defaults to |
sig.level |
significance level used in test. Defaults to 0.05. |
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.
Both the alternative and the null are simulated under the parametric scenario estimated from the data matrix x
. This possibly induces a discrepancy with chisq.test.simulate
, where the null also is simulated from the specific data instance. Thus, the problem is that the null distribution depends on the model parameters.
An object of class "power.htest"
.
The code has not been optimized for speed, and might be slow.
Bo Markussen
chisq.test.simulate
# 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. power.chisq.test.simulate(Xobs,"row") power.chisq.test.simulate(Xobs,"total")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.