Computes the Pearson's Chi-squared test of independence for each
row vector in x
.
See the Details section below for further information.
Arguments
- x
matrix
ordata.frame
.- g
a vector or factor object giving the group for the corresponding elements of
x
.- correct
a logical indicating whether to apply continuity correction when computing the test statistic for 2 by 2 tables: one half is subtracted from all \(|O - E|\) differences; however, the correction will not be bigger than the differences themselves. No correction is done if
simulate.p.value = TRUE
.- simulate.p.value
a logical indicating whether to compute p-values by Monte Carlo simulation.
- B
an integer specifying the number of replicates used in the Monte Carlo test.
Value
A list containing two elements:
- statistic
A numeric vector, the values of the test statistic
- significance
A numeric vector, the p-values of the selected test
Details
It is a wrapper to chisq.test
function.
Examples
#Seed
set.seed(1010)
#Data
x = rbind(
matrix(sample(c("mut", "wt"),30,TRUE), 1, 30),
matrix(sample(c("m", "f") ,30,TRUE), 1, 30)
)
g = sample(c("a","b","c"), 30, replace = TRUE)
#Compute
rowPearsonChiSq(x = x, g = g, simulate.p.value = TRUE)
#> $statistic
#> [1] 0.2020202 2.5689935
#>
#> $significance
#> [1] 1.0000000 0.3098451
#>