# LRT.stat: Likelihood ratio test statistic for contingency tables In MADPop: MHC Allele-Based Differencing Between Populations

## Description

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

## Usage

 `1` ```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 ∑_ij O_ij log(p_ij/p_0j),

where O_ij is the observed number of counts in the ith row and jth column of `tab`, p_ij = O_ij/(∑_j O_ij) is the unconstrained estimate of the proportion of category j in population i, and p_0j = ∑_i O_ij / ∑_ij 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

 ```1 2 3 4 5 6``` ```# 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 ```

### Example output

```Loading required package: rstan