Biology, images, analysis, design...
|"It has long been an axiom of mine that the little things are infinitely the most important" |
Pearson's chi square test of independenceOn this page: Models & study designs Large-sample tests Exact tests using the X2 statistic Assumptions
Models & study designs
This test is used to assess whether paired observations on two (usually nominal) variables are independent of each other. It thus enables us to determine if there is a significant difference between two independent proportions. The frequencies in each category are arranged in a contingency table. The test statistic is Pearson's chi square statistic (X2) as defined below. It's precise distribution depends on the sampling model.
The original Pearson's chi square statistic assumes a multinomial model with only the total number of observations fixed. This can arise from two possible sampling designs:
A single random sample is taken (analytical survey) and individuals are classified according to two characteristics. For example we might take a random sample of 2000 adult men aged 18-25 and determine whether each is married or single, and whether each is positive or negative for the HIV virus. We then compare the proportion of married men with the virus with the proportion of single men with the virus.
Individuals are randomly allocated to two treatment groups (completely randomized experimental design) and in each group the frequencies with and without a particular characteristic are recorded. For example, individuals with malaria are randomly allocated to two treatment groups in which patients are given either drug A or drug B. The proportion of patients suffering neuropsychiatric side effects is compared between drug A and drug B. Note that in practice most experiments use some form of restricted randomization so that numbers in each treatment group are (more or less) fixed (see below).
Independent binomial model
In the second model either row or column totals are fixed (giving a double binomial model), but the other marginal totals are free to vary.
Two random samples are taken (comparative area observational design) and in each sample the frequencies with and without a particular characteristic are recorded. For example, we take two random samples, one from a rural area and the other from an urban area, each of 1000 adult men. We then compare the proportion of infected men from rural areas with the proportion of infected men from urban areas. The same model applies for cohort or case-control designs, and randomized trials where restricted randomization is used to equalize group sizes for each treatment.
The exact distributions of X2 obtained under the two different models differ somewhat. However the asymptotic distribution of the statistic for both models is chi square with
Large sample tests
The test statistic - X2 known as Pearson's chi square - can be calculated from the following general formula:
This formula can also be used for goodness of fit tests and for contingency tables with more than two rows or columns.
For 2 × 2 contingency tables there is an alternative computational formula that is preferred as it is less subject to rounding errors:
The value of X2 is referred to the probability calculator on your software package, or to a table of χ2 values at
When the chi square test is used as a test of association it is naturally two sided since the null hypothesis is of no association versus the alternative of some association. However, when it is being used to compare two proportions (in other words for a 2 × 2 table), a one-sided test might be required. This is obtained by simply halving the P-value given by Pearson's chi square statistic.
Correction for continuity
For small sample sizes, many - but not all -
The Yates correction for the computational formula is shown below:
The correction is usually only recommended if the smallest expected frequency is less than 5. Note that the correction should not be applied if
The 'n − 1' chi-square test
Exact tests using the X2 statistic
Monte Carlo solutions
We used this approach to compare our result with that given by Ludbrook (2008) for the independent binomial model (termed by Ludbrook the comparative trial or singly conditioned 2×2 table). Group 1 had 14 dead and 9 alive, so p1 = 0.6087. Group 2 had 17 dead and 2 alive so p2 = 0.8947. Ludbrook considered that the P-value of 0.044 obtained by the package Testimate for the single-conditioned option for exact tests on an odds ratio of 1, a risk ratio of 1 and a risk difference of 0 was acceptable. The P-value of 0.0391 obtained by StatXact for exact tests on a risk ratio of 1 and a risk difference of 0 was also deemed acceptable. Our exact Monte Carlo X2 test for these data with one million replicates gave a similar P-value of 0.0381.
Sampling or allocation is randomFor model 1 (multinomial).
Observations are independent
Observations are assumed to be independent of each other. This assumption is not met if (for example) samples are obtained from clusters, or cluster randomization is used, and the test is then used to analyze results at an individual level. However, there is an approximate correction which can be applied to the chi square test for used with cluster samples which we cover in
Errors are normally distributed
Both models assume errors are normally distributed. Providing the cell frequencies are reasonably large, cell values in a 2 × 2 table will be distributed normally about their expected values. If any expected frequency is less than 5, then providing you want a conventional P-value, the continuity correction should be applied. Omission of the continuity correction will give you a mid-P-value. For very small sample sizes the conventional wisdom has been to use Fisher's exact test, although use of an exact test based on the correct model is now preferred.
A given case may fall only in one class.
Related topics :