Test in a two-way contingency table with the row margin fixed.

onemargintest(x, B = 10000L)

Arguments

x

A matrix representing the contingency table.

B

The number of simulations used to compute the p-value.

Value

A list of class "htest" giving the simulation results.

Details

Simulation is done by random sampling from the set of all tables with given row marginals, and works only if the marginals are strictly positive. Continuity correction is never used, and the statistic is quoted without it.

Examples

m <- matrix(c(12, 4, 8, 6), 2) chisq.test(m)
#> Warning: Chi-squared approximation may be incorrect
#> #> Pearson's Chi-squared test with Yates' continuity correction #> #> data: m #> X-squared = 0.41853, df = 1, p-value = 0.5177 #>
chisq.test(m, correct=FALSE)
#> Warning: Chi-squared approximation may be incorrect
#> #> Pearson's Chi-squared test #> #> data: m #> X-squared = 1.0714, df = 1, p-value = 0.3006 #>
fisher.test(m)
#> #> Fisher's Exact Test for Count Data #> #> data: m #> p-value = 0.4421 #> alternative hypothesis: true odds ratio is not equal to 1 #> 95 percent confidence interval: #> 0.3748465 14.3417410 #> sample estimates: #> odds ratio #> 2.188389 #>
onemargintest(m)
#> #> Two-sided contingency table test with row margin fixed #> #> data: #> X-squared = 1.0714, p-value = 0.3584 #>
m2 <- matrix(c(9, 3, 3, 7), 2) chisq.test(m2, simulate.p.value=TRUE)
#> #> Pearson's Chi-squared test with simulated p-value (based on 2000 #> replicates) #> #> data: m2 #> X-squared = 4.455, df = NA, p-value = 0.08096 #>
fisher.test(m2)
#> #> Fisher's Exact Test for Count Data #> #> data: m2 #> p-value = 0.08356 #> alternative hypothesis: true odds ratio is not equal to 1 #> 95 percent confidence interval: #> 0.801019 68.433319 #> sample estimates: #> odds ratio #> 6.311273 #>
onemargintest(m2)
#> #> Two-sided contingency table test with row margin fixed #> #> data: #> X-squared = 4.455, p-value = 0.0377 #>