LRT.stat: Likelihood ratio test statistic for contingency tables

View source: R/LRT.stat.R

LRT.statR Documentation

Likelihood ratio test statistic for contingency tables

Description

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

Usage

LRT.stat(tab)

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 ith row and jth 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.

Value

The calculated value of the LRT 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
LRT.stat(ctab) # likelihood ratio statistic

mlysy/MADPop documentation built on Feb. 28, 2024, 12:29 p.m.