Two by Two

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Two by Two Tables Containing Counts (TwobyTwo)

Kevin M. Sullivan, PhD, MPH, MHA, Associate Professor, Department of Epidemiology, Rollins School
of Public Health, Emory University, Atlanta, Georgia, USA

INTRODUCTION Point and Variance Estimates, Confidence intervals


This chapter provides the formulae and examples for
calculating crude and adjusted point estimates and The point and variance estimates and the confidence
confidence intervals for: risk ratios and differences; odds interval formulae are provided in Table 15.1. For some
ratios; incidence rate ratios and differences; and etiologic parameters there will not be a variance formula. The
and prevented fractions. The tests for interaction are confidence limits for the Etiologic Fraction in the
also presented. First, the estimates from a single 2x2 Exposed is based on the calculated upper lower bounds
table (“count” data) are presented followed by estimates of the confidence limits for the risk ratio (RRUB and
adjusted or summarized across stratified data. RRLB, respectively) with risk data. A similar approach is
used when the Etiologic Fraction in the Exposed is based
FORMULAE AND EXAMPLE FOR A SINGLE on the Odds Ratio.
2X2 TABLE (COUNT DATA)
Statistical Tests
For a single 2x2 table, the notation is as depicted in
table 15-1. The formulae for calculating the risk ratio, There are many statistical tests that can be
risk difference, and odds ratio and their confidence performed on a single 2x2 table. Common tests include
intervals are shown below. For the confidence intervals, the Chi-square test (corrected, uncorrected, and Mantel-
the Taylor series approach is provided because it is a Haenszel) and exact tests (Fisher and mid-p exact). In
reasonably good confidence interval method when the this chapter the uncorrected and Mantel-Haenszel chi-
sample size is large. There are other more complicated square tests will be presented; however, these test should
methods for computing confidence intervals when the be used when the number of “expected” observations in
data are sparse but they are not shown here, such as each cell are > 5. When the expected number of
maximum likelihood and exact methods. Note that the observations in any cell is < 5, then one of the exact tests
term “risk” is used assuming a cohort study was should be used. How to calculate exact p-values is
performed and the risk of disease was assessed. If a beyond the scope of this text and requires an iterative
study was based on prevalent disease, then substitute the calculation. The expected number of observations in a
term “prevalence” for “risk,” e.g., prevalence ratio and cell is calculated by multiplying the row and column
prevalence difference. total and dividing by the total sample size.

Table 15-1. Notation and table setup for a 2x2 The uncorrected chi square is calculated as
table
Exposed Nonexposed (n)( ad  bc) 2
Disease a b m1 uncorr 12 
n1 n0 m1m0
No Disease c d m0
n1 n0 n
and the Mantel Haenszel chi square as

Estimated risk in the exposed = Rˆ e  a / n1


(n  1)(ad  bc) 2
Estimated risk in the nonexposed = Rˆ u  b / n0 mh 12 
n1 n0 m1m0
Estimated risk in the population = Rˆ  m / n
1

1
Table 5.1. Estimates and confidence intervals for epidemiologic parameters for a single table
Parameter Point Estimate Variance Estimate Confidence Interval
Parameters based on risks (from randomized trials and cohort studies) or prevalences (cross-sectional studies)
Risk Ratio Rˆ e
Rˆ R 
1 - R̂e 1  R̂u
Vaˆr (ln Rˆ R )  
ˆ RRexp  Z1 - /2 Vaˆr (ln RR) 
 ˆ
 
Rˆ u n1R̂e noR̂u
Risk Difference Rˆ D  R̂e - Rˆ u Rˆ e(1  Rˆ e) Rˆ u(1  Rˆ u)
Vaˆr ( Rˆ D)   Rˆ D  Z 1   / 2 Vaˆr ( Rˆ D )
n1 n0
Etiologic Fraction Rˆ  Rˆ u
in the Population EFˆp 

Etiologic Fraction Rˆ e  Rˆ u Based on variance estimate for the RR Rˆ RLB  1 Rˆ RUB  1
in the Exposed EFˆe  LB= ;UB=
Rˆ e Rˆ RLB Rˆ RUB
Prevented Rˆ u  Rˆ
Fraction in the PFˆ p 
Population Rˆ u
Prevented Rˆ u  R̂e Based on variance estimate for the RR LB= 1  Rˆ RUB ; UB= 1  Rˆ RLB
Fraction in the P Fˆ e 
Exposed Rˆ u
Parameters based on the odds and odds ratio (from randomized trials, cohort studies, case-control, or cross-sectional
studies)
Odds Ratio ad 1 1 1 1 ˆ  ˆ 
Oˆ R  Vaˆr (ln Oˆ R)     ORexp  Z1 - /2 Vaˆr (ln OR)
 
bc a b c d
Etiologic Fraction EFˆpOR 
in the Population
p' (ORˆ  1)
p ' (ORˆ  1)  1
Etiologic Fraction Oˆ R  1 Based on variance estimate for the OR Oˆ RLB  1 Oˆ RUB  1
in the Exposed EFˆeOR  LB= ;UB=
Oˆ R Oˆ RLB Oˆ RUB
Prevented PFˆpOR 
Fraction in the
Population p ' (1  Oˆ R)
Prevented PFˆ eOR  1  Oˆ R Based on variance estimate for the OR LB= 1  Oˆ RUB ; UB= 1  Oˆ RLB
Fraction in the
Exposed
LB=lower bound; UB=upper bound
P’=…

To work through an example of the calculations,


a study was performed in children 12-23.9 months of The prevalence estimates are:
age. In this study, the prevalence of anemia was
estimated. The results are shown in Table 15-2. Prevalence in males = 205/294 = 0.697 or 69.7%
Prevalence in females = 129/215 = 0.600 or 60.0%

Table 15-2. Example data; prevalence of anemia The Prevalence Ratio estimate is as follows (using the
in children 12-23.9 months of age by sex formulae for the risk ratio):

Male Female Prevalence ratio = .697/.600 = 1.16


Anemic 205 129 334
Not Anemic 89 86 175 Variance of the prevalence ratio =
294 215 509
2
1 - .697 1  .6
  .004579 The interpretation would be that the odds of
294 * .697 215 * .6
anemia in males is 1.54 times the odds in females with a
95% confidence interval of 1.06 to 2.23. Note that the
95% confidence interval; replace the Z value in the
odds ratio is larger than the risk ratio because the
formula to 1.96 for the calculation of a two-sided 95%
confidence interval (for a 90 confidence interval, the Z prevalence of anemia is high (334/509 = 66%).
value is 1.645, and for a 99% confidence, 2.576):
The uncorrected chi-square tests would be
calculated as:
 
1.16exp  1.96 .004579  1.16 exp .132629
(509)( 205  86  129  89) 2
(1.02, 1.32) uncorr 12   5.20903
294  215  334  175
The interpretation would be that males in this
study were 1.16 times more likely to have anemia than which would have a p-value = .022. The Mantel
females; the 95% confidence interval around this Haenszel chi square would be calculated as:
estimate is 1.02, 1.32.
(509  1)(205  86  129  89) 2
The Prevalence Difference estimate is as follows mh 12   5.19879
(using the formulae for the risk difference): 294  215  334  175
which would have a p-value of .023. The
Prevalence difference = .697 - .600 = .097 or 9.7% conclusion would be that there was a statistically
significant association between the sex of the child
Variance of the prevalence difference = and the prevalence of anemia. Note that the
statistical test for a 2x2 table can be used with the
.697(1  .697) .6(1  .6) risk ratio, risk difference, or odds ratio. Also, it is
  .0018346
294 215 calculated the same whether the data are from an
unmatched case-control study, a cohort study, or a
95% confidence interval: clinical trial.

.097  1.96 .0018346  .097  1.96(.04283) FORMULAE AND EXAMPLE FOR


STRATIFIED DATA (COUNT DATA)
(.013, .181) or (1.3%, 18.1%)
For stratified analyses, the same calculations for
The interpretation would be that the prevalence the crude table can be used for stratum-specific
of anemia is 9.7% higher in males compared to females estimates. For adjusted or summary estimates, a slightly
(in terms of an absolute difference), with a 95% different notation is used as shown in Table 15-2. In this
confidence interval from 1.3% to 18.1%. table, the subscript i to denote estimates from a specific
stratum. The general approach for adjusted point
The odds ratio estimate, or in this example the estimates is to weight each of the stratum-specific
prevalence odds ratio estimates, is as follows: estimates by a weighting method and then sum the
results.
Odds ratio = (205*86)/(129*89)=1.54
Table 15-2. Notation and table setup for stratified
Variance of the odds ratio = 2x2 tables
Exposed Nonexposed
1 1 1 1 Disease ai bi m1i
    .0354938 No Disease
205 129 89 86 ci di m0i
n1i n0i ni
95% confidence interval =
For the risk ratio and the odds ratio, two
 
1.54exp  1.96 0.0354938  1.54 exp .369258 different approaches are given for estimating the
adjusted point estimate and confidence interval, one
referred to as the directly adjusted ratio and the other
(1.06, 2.23)
3
referred to as the Mantel-Haenszel adjusted ratio. The Mantel-Haenszel method works better when data are
directly adjusted approach requires “large” numbers in sparse.
each stratum. The weights for directly adjusted values
are the inverse of the variance; this approach provides a
greater weight to strata with the least amount of variance
and less weight to strata with a large variance. The

4
Parameter Point Estimate Confidence Interval
Risk Ratio – The link ed image cannot be displayed. The file may hav e been mov ed, renamed, or deleted. Verify that the link
po ints to the correct file and location.
 
Directly  
 Z 1 / 2 
Adjusted Rˆ RDirect exp  
s
 wi 
 
where  i 1 
The link ed image cannot be
displayed. The file may hav e
been mov ed, renamed, or
deleted. Verify that the link
po ints to the correct file and
location.
The link ed image cannot be displayed. The file may hav e been
mov ed, renamed, or deleted. Verify that the link points to the correct

, file and location.

Risk Ratio – a i noi s The link ed image cannot be displayed. The file may hav e been mov ed, renamed, or deleted. Verify that the link
po ints to the correct file and location.

Mantel-  n where
Haenszel Rˆ RMH  i s1 i
bi n1i s
Adjusted 
i 1 ni
 m 1i 1i n n0i  a i bi ni  / ni2

SE ln Rˆ RMH   i 1

 s ai n0i   s bi n1i 
   
 i 1 ni   i 1 ni 
Risk s
Z
Difference –  w Rˆ D i i Rˆ DDirect  1 / 2
s
Directly Rˆ DDirect  i 1
s w i
Adjusted w
i 1
i
i 1

where
1 a b
wi  , Rˆ Di  i  i
ai c i bi d i n1i n0i
3
 3
n1i n0 i

Odds Ratio –  s   
Directly   wi ln( Oˆ Ri )   
   Z 
Adjusted Oˆ R Direct  exp i 1 s  Oˆ RDirect exp  1 / 2 
s
  
  wi  

 wi 

 i 1  i 1

where
ad 1
Oˆ Ri  i i , wi 
bi ci 1 1 1 1
  
ai bi ci di

Odds Ratio –
Mantel-
ai d i

s
Oˆ R MH exp  Z1-/2 SE lnOˆ RMH   
n where
Haenszel Oˆ RMH  i s1 i
bi ci
Adjusted i 1 ni

5

SE lnOˆ RMH 
s s s

 Pi Ri
i 1
 ( Pi S i  Qi Ri )
i 1
Q S
i 1
i i

2
 s s
 2
 s  2 Ri  S i  s 
2 Ri  2  S i 
i 1 i 1
 i 1   i 1 
Pi  ( ai  di ) / ni
Qi  (bi  ci ) / ni
Ri  ai di / ni
Si  bi ci / ni

6
Tests for Interaction for the Risk Ratio, Risk Difference, and the Odds Ratio

The tests for interaction presented here are generally referred to as the “Breslow-
Day test of homogeneity” and are based on a chi square test.
The test for interaction for the risk ratio is:

 s21 
  
s ln Rˆ R  ln Rˆ R
i Direct 2
i 1  ˆ
Vaˆr ln( RRi ) 
where the Var[ln(RRi)] = 1/wi from the direct RR point estimate calculation.

The test for interaction for the risk difference is

 2


s Rˆ D  Rˆ D
i Direct 
2

s 1
i 1
ˆ
Vaˆr ( RDi )

where the Var(RDi) = 1/wi from the direct RD point estimate calculation.

To test for interaction for the odds ratio (OR), the chi square test is calculated as:

 2

  
i 
s ln Oˆ R  ln Oˆ R
Direct
2

s 1
i 1   ˆ
Vaˆr ln(OR ) i

where the Var[ln(ORi)] = 1/wi from the direct OR point estimate calculation.

Summary Statistical Test

A statistical test to assess whether there is a statistically significant association


between the exposure and outcome variable controlling for the third variable is the
Mantel-Haenszel uncorrected chi-square test. This statistic would be used only if it was
decided that there was no statistically significant interaction.

2
 s ai d i  bi c i 
  
2  i 1 ni 
1  s
n1i n0i m1i m0i

i 1 n i  1n i
2

An example of the calculations for stratified data are provided next. Continuing
on with the example in table 15-3 on the association between sex and anemia in children,

7
the data are stratified on mothers education level. Again, because the data were based on
prevalent cases, the term “prevalent” will be used rather than “risk.”

Table 15-3. Example data; prevalence of anemia in children 12-23.9 months of age by
sex stratified on mothers education level.

Mother has low level of education


Male Female
Anemic 66 36 102
Not Anemic 28 32 60
94 68 162

Mother has high level of education


Male Female
Anemic 139 93 232
Not Anemic 61 54 115
200 147 347

Calculation of the directly adjusted prevalence ratio and its 95% confidence interval is
shown in Table 15-4.

Table 15-4. Calculations for computing directly adjusted prevalence (risk) ratio
Stratum PRi ln(PRi) wi wi ln(PRi)
1 1.326 .2821669 56.86628 16.04578
2 1.099 .0944001 162.75481 15.36407
Sum 219.62109 31.40985

The calculated point estimate is:

 31.40985 
Pˆ RDirect  exp    1.154
 219.62109 

The 95% confidence interval is:

 1.96 
1.154 exp    1.154 exp .132257 
 219.62109 

(1.011, 1.317)

The interpretation would be that males were 1.154 times more likely to be anemic than
females controlling or adjusting for the mother’s education level. In addition, we are 95%
confident that the true prevalence ratio is captured between 1.011 and 1.317. However, we must
still calculate the test for interaction to see if the mother’s education level modifies the sex-
anemia relationship. To calculate the test for interaction, the directly adjusted risk ratio needs to
be calculated beforehand. Also, note that

8
1
vâr(ln Pˆ Ri ) 
wi

Therefore, the test for interaction for the prevalence/risk ratio would be:

 s21 
.2821669  .1432342  .0944001  .1432342
.017585 .0061442
2
 s 1  1.097660  .388130  1.485790

The p-value for the chi square would be calculated for a chi square value of 1.486 with
one degree of freedom (the degrees of freedom is determined from the number of strata minus 1).
The p-value from this example is .223. Therefore, we would state that the mother’s education
level does not significantly modify the sex-anemia relationship. Therefore, the next question is
whether the mother’s education level confounds the relationship. The crude prevalence ratio was
1.16 and the directly adjusted value was 1.15, which is less than a 1% difference, therefore the
conclusion would be that mother’s education does not modify nor confound the sex-anemia
relationship.

The calculation of the directly adjusted Mantel-Haenszel prevalence ratio and its 95%
confidence interval is shown in Table 15-5.

Table 15-5. Calculations for computing the Mantel-Haenszel prevalence (risk) ratio
Stratum ain0i/ni bin1i/ ni (m1in1in0i-
aibini)/ni2
1 27.7037 20.8889 10.17650
2 58.8847 53.6023 19.3933
Sum 86.5884 74.4912 29.5698

The point estimate is

86.5884
Pˆ RMH   1.162
74.4912

To calculate the 95% confidence interval we will first calculate the standard error of the
estimate:

29.5698

SE lnPˆ R MH   86.5884 * 74.4912
 .067708

The 95% confidence interval is calculated as:

1.162 exp 1.96.067708  1.162 exp( .132708)

(1.018, 1.327)

Previously we found that mother’s education did not modify the sex-anemia relationship,
therefore the interpretation would be that, controlling for mother’s education, males were 1.162

9
times more likely to be anemic than females. However, because there is little confounding (the
crude value is 1.15), there is no need to control for mother’s education level.

Calculation of the directly adjusted prevalence difference and its 95% confidence interval is
shown in Table 15-6.

Table 15-6. Calculations for computing the direct adjusted prevalence (risk) difference
Stratum PDi wi wi PDi
1 0.1727 169.8171 29.3274
2 0.0623 378.6661 23.5909
Sum 548.4832 52.9183

The point estimate is:

52.9183
Pˆ DDirect   .0965
548.4832

and the 95% confidence interval is:

1.96
.0965   .0965  .0837
548.4832

(.0128, .1802)

Depending on the frequency of disease, it may be useful to describe the difference in term
of per 100 individuals (or percent), per 1,000, or some other unit. In this example, the males had
a prevalence of anemia 9.7% higher (in absolute terms) than females controlling for maternal
education, and we are 95% confident that the truth is captured between 1.3% and 18.1%.
However, before the decision is made as to whether or not to present the adjusted difference, the
test for interaction should be calculated. Again, note that:

1
vâr(ln Pˆ Di ) 
wi

Therefore, the test for interaction for prevalence/risk differences would be:

 2

0.1727  .0965 0.0623  .0965
2

2

s 1
.00589 .00264

.98581  .44305  1.42886

The chi square value of 1.42886 with one degree of freedom would have a p-value of
.232, which would not be statistically significant. The next step would be to determine whether
mother’s education confounds the sex-anemia relationship. The crude prevalence difference was
.097, the same as the adjusted difference, which would lead to the conclusion that there is no
important confounding in this analysis.

10
Calculation of the directly adjusted (prevalence) odds ratio and its 95% confidence interval
is shown in Table 15-7.

Table 15-7. Calculations for computing the direct adjusted (prevalence) odds ratio
Stratum ORi ln(ORi) wi wi ln(ORi)
1 2.095 .73955 9.09971 6.72969
2 1.323 .27990 18.91829 5.29523
Sum 28.01800 12.02492

The calculated point estimate is:

12.02492 
Oˆ RDirect  exp    1.536
 28.018 

The 95% confidence interval is:

 1.96 
1.536 exp    1.536 exp  .370286
 28.018 

(1.061, 2.224)

The interpretation would be that odds of anemia in males was 1.536 times the odds of
anemia in females controlling or adjusting for the mother’s education level. In addition, we are
95% confident that the true prevalence odds ratio is captured between 1.061 and 2.224. However,
we must still calculate the test for interaction to see if the mother’s education level modifies the
sex-anemia relationship. To calculate the test for interaction, the directly adjusted odds ratio
needs to be calculated beforehand. Also, note that

1
vâr(ln Oˆ Ri ) 
wi

Therefore, the test for interaction for the (prevalence) odds ratio would be:

 s21 
.73955  .429182  .27990  .429182
.10989 .05286
2
 s 1  .87660  .42158  1.2918

The p-value for the chi square would be calculated for a chi square value of 1.2918 with
one degree of freedom (the degrees of freedom is determined from the number of strata minus 1).
The p-value from this example is .256. Therefore, we would state that the mother’s education
level does not significantly modify the sex-anemia relationship. Therefore, the next question is
whether the mother’s education level confounds the relationship. The crude prevalence odds ratio
was 1.536 and the directly adjusted value was the same, the conclusion would be that, based on
the odds ratio, mother’s education does not modify nor confound the sex-anemia relationship.

Calculation of the Mantel-Haenszel adjusted (prevalence) odds ratio and its 95%
confidence interval is as follows. The values that need to be calculated are shown in Table 15-8.

11
To calculate the point estimate and the confidence interval, eight values in Table 15-8 need to be
calculated.

The calculated point estimate is:

34.66816
Oˆ RMH   1.536
22.57092

The standard error of the natural log of the point estimate is calculated as:

Table 15-8. Calculations for computing the Mantel-Haenszel adjusted (prevalence)


odds ratio
Stratum Pi Qi Ri Si
1 .60494 .39506 13.03704 6.22222
2 .55620 .44380 21.63112 16.34870
Sum 1.16114 .83886 34.66816 22.57092

Stratum PiRi PiSi QiRi QiSi


1 7.88663 3.76407 5.15041 2.45815
2 12.03123 9.09315 9.59999 7.25555
Sum 19.91786 12.85722 14.75040 9.71370


SE lnOˆ RMH 
19.91786 12.85722  14.75040 9.71370
 
234.66816 2 x34.66816 x 22.57092 222.570922
2

 .00829  .01764  .00953  .18831

The confidence interval based on the Robins, Greenland, Breslow method is:

1.536 exp  1.96.18831


1.536 exp( .36908)

The 95% confidence interval is

(1.062, 2.222)

Previously we found that mother’s education did not modify the sex-anemia relationship,
therefore the interpretation would be that, controlling for mother’s education, the odds of males
having anemia were 1.536 times more likely to be anemic than the odds in females. However,
because there is little or no confounding (the crude value is 1.536), there is no need to control for
mother’s education level.

The overall Mantel-Haenszel uncorrected chi-square test would be calculated as with the
intermediate calculations shown in Table 15-9.

12
Table 15-9. Calculations for computing the Mantel-Haenszel uncorrected chi-square
test
Stratum (aidi-bici)/ni (n1in0im1i m0i)/[(ni-1)ni2]
1 6.81481 9.25832
2 5.28242 18.82774
Sum 12.09723 28.08606

Therefore

 12 
12.097232  5.2105
28.08606

which would have a p-value of .022.

13

You might also like