Learn R Programming

MADPop (version 1.1.7)

LRT.stat: Likelihood ratio test statistic for contingency tables

Description

Calculate the likelihood ratio test statistic for general two-way contingency tables.

Usage

LRT.stat(tab)

Value

The calculated value of the LRT statistic.

Arguments

tab

A K x C matrix (contingency table) of counts. See details.

Details

Suppose that tab consists of counts from \(K\) populations (rows) in \(C\) categories. The likelihood ratio test statistic is computed as $$ 2 \sum_{i=1}^K \sum_{j=1}^N O_{ij} \log(p^A_{ij}/p^0_{j}), $$ where \(O_{ij}\) is the observed number of counts in the \(i\)th row and \(j\)th column of tab, \(p^A_{ij} = O_{ij}/\sum_{j=1}^C O_{ij}\) is the unconstrained estimate of the proportion of category \(j\) in population \(i\), and \(p^0_j = \sum_{i=1}^K O_{ij} / \sum_{i=1}^K\sum_{j=1}^C O_{ij}\) is the estimate of this proportion under \(H_0\) that the populations have indentical proportions in each category. If any column has only zeros it is removed before calculating the LRT statistic.

Examples

Run this code
# simple contingency table
ctab <- rbind(pop1 = c(5, 3, 0, 3),
                pop2 = c(4, 10, 2, 5))
colnames(ctab) <- LETTERS[1:4]
ctab
LRT.stat(ctab) # likelihood ratio statistic

Run the code above in your browser using DataLab