power.chisq.test.simulate {LabApplStat}R Documentation

Simulate power of Chi-squared tests with conditioning

Description

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.

Usage

power.chisq.test.simulate(
  x,
  conditioning = "total",
  x0 = NULL,
  sig.level = 0.05,
  B = 10000
)

Arguments

x

matrix specifying the alternative distribution of the contingency table.

conditioning

character string specifying the simulation scenario. Defaults to "total". Other possible scenarios are "row", "col", and "both".

x0

matrix specifying the null distribution. Defaults to NULL, in which case the null is estimated from the alternative x.

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.

Details

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.

Value

An object of class "power.htest".

Note

The code has not been optimized for speed, and might be slow.

Author(s)

Bo Markussen

See Also

chisq.test.simulate

Examples

# 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")


[Package LabApplStat version 1.4.4 Index]