chi2.stat {MADPop} | R Documentation |
Chi-squared test statistic for contingency tables
Description
Calculates the chi-squared test statistic for a two-way contingency table.
Usage
chi2.stat(tab)
Arguments
tab |
A |
Details
Suppose that tab
consists of counts from populations (rows) in
categories. The chi-squared test statistic is computed as
where is the observed number of counts in the
th row and
th column of
tab
, and is the expected number of counts under
that the populations have indentical proportions in each category:
where is the total number of counts in
tab
.
Value
The calculated value of the chi-squared statistic.
Examples
# simple contingency table
ctab <- rbind(pop1 = c(5, 3, 0, 3),
pop2 = c(4, 10, 2, 5))
colnames(ctab) <- LETTERS[1:4]
ctab
chi2.stat(ctab) # chi^2 test statistic
[Package MADPop version 1.1.7 Index]