Skip to contents

Pearson's X^2 with p = (1 + #(X^2_b >= X^2)) / (B + 1) over B tables drawn by r2dtable with the observed margins, as chisq.test(simulate.p.value = TRUE) (Hedderich, Sachs & Reynarowych 2023, p. 739).

Usage

chisqmc(table, B = 2000, seed = NULL)

Arguments

table

r x c matrix of counts.

B

Number of simulated tables.

seed

Optional seed; the caller's RNG state is restored.

Value

Named list: statistic, p_value, B.

References

Hope, A. C. A. (1968). JRSS B 30, 582-598.

Examples

chisqmc(matrix(c(14, 22, 32, 18, 16, 8, 8, 2, 0), 3, byrow = TRUE), B = 500, seed = 1)
#> $statistic
#> [1] 21.57647
#> 
#> $p_value
#> [1] 0.001996008
#> 
#> $B
#> [1] 500
#>