2x2 Contingency Tables: Handy Reference Sheet - Hrp/Stats 261, Discrete Data

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Binary predictor Binary outcome

HANDY REFERENCE SHEET HRP/STATS 261, Discrete Data 2x2 Contingency Tables
Exposed (E) Unexposed (~E) Measures of Association Risk Ratio = Disease (D) a c No Disease (~D) b d

a /( a + b) c /(c + d )
1 a /( a + b ) 1 c /( c + d ) + 1.96 a c 1 a /( a + b ) 1 c /( c + d ) + +1.96 a c

95% CI:

RR * exp

, RR * exp

Odds Ratio =

ad bc
1 1 1 1 + + + 1.96 a b c d 1 1 1 1 + + + + 1.96 a b c d

95% CI:

OR * exp

, OR * exp

Difference in Proportions: H0: p D / E p D / ~ E = 0 [for case-control study: p e / d p e / ~ d = 0 ] Test Statistic:


p d / e p d / ~e ~Z ( p d / e )(1 p d / e ) ( p d / ~ e )(1 p d / ~ e ) + ne n~e 95% CI: ( p d / e p d / ~ e ) 1.96 * ( p d / e )(1 p d / e ) ( p d / ~ e )(1 p d / ~ e ) + ne n~e

SAS CODE: proc freq data=yourdata; tables yourExposure*yourOutcome /measures cl; weight counts; *if you have grouped data; run;

2x2xK Contingency Tables

Binary predictor Binary outcome Categorical covariate

Notation: outcome=d; predictor=e; categorical covariate=k Steps 1. Calculate crude ORd-e (or RRd-e) 2. Calculate stratum-specific ORs: ORd-e/k=K 3. If crude OR and stratum-specific ORs are all similar STOP. k is unlikely to be a confounder or an effect modifier, and you may use usual methods for 2x2 table (see page i), ignoring k. 4. If crude OR and stratum-specific ORs differproceed to (a) or (b) below: a) If stratum-specific ORs are similar to each other suspect confounding (i) Apply Cochran-Mantel-Haenszel test of conditional independence: H0: e and d are conditionally independent. Test Statistic:
Disease Exposed Unexposed No Disease b d

(a
i =1 k

E(a k ))] 2 ~ 1
k 2 E(a k ) =

a
c

Var (a
i =1

( a + b) k ( a + c ) k ; where n k = total in stratum k nk (a + b) k (a + c) k (b + d ) k (c + d ) k


2 nk (nk 1)

Var (a k ) =

(ii) Calculate Mantel-Haenszel (MH) summary OR (adjusted for confounding by k). If you rejected the null in (i), then MH OR should be 1.0. If you did not reject null in (i), then MH OR should be 1.0.

OR d e / k =


i =1 i =1 k

ai d i Ti bi ci Ti

For RR:
RRd e / k =


i =1 i =1 k

a i (c i + d i ) Ti ci ( ai + bi ) Ti

b) If stratum-specific ORs differ from each other suspect interaction (effect modification) (i) Apply Breslow-Day test of homogeneity of the ORs: H0: stratum-specific ORs are equal (homogenous) Test Statistic: complex use computer software If you reject null effect modification is present. Report stratumspecific ORs If you fail to reject null insufficient evidence of effect modification; calculate Mantel-Haenszel summary OR, as above. SAS CODE: proc freq data=yourdata; tables yourCovariate*yourExposure*yourOutcome /cmh; weight counts; *if you have grouped data; ii

run;

iii

Categorical Variables that lack clear predictor/outcome distinction

Multi-way Contingency Tables:


Notation: x, y, and z are categorical variables Chi-square test of independence (RxC table): H0: x, y, and z are independent Test Statistic:

(Observed Expected ) 2 ~ 2 ( rows 1)( columns 1) Expected cells

Log-Linear Model
log(counts ) = + x x + y y + z z + interactions if appropriate

Odds ratio interpretation (if 2x2 table):


log(ORd e ) = log( log( ad ) = log a + log d log b log c bc

ad ) = ( + d + e + d *e ) + ( ) ( + d ) ( + e ) = d *e bc OR = e d *e

SAS CODE: Chi-square test proc freq data=yourdata; tables yourX*yourY*yourK / chisq; weight counts; *if you have grouped data; run; Log-linear models proc genmod data=yourdata; model total = yourX yourY yourK YourInteractions / dist=poisson link=log pred; run;

iv

Unrestricted predictors and covariates Binary outcome

Logistic Regression
Model:
p ln( ) = + 1 x1 + 2 x 2 + .... 1 p

Simplest form of the logistic likelihood (from 2x2):


l( ) = ( e + e 1+ e
+e

) a x(

1 1+ e
+e

) b x(

e c 1 d ) x( ) 1 + e 1 + e

Tests of Model Fit: Wald Test


Z= 0 asymptotic standard error ( )

Exposed Unexposed

Disease a c

No Disease b d

Likelihood Ratio Test: where full model has n parameters and reduced model has n-p
2 ln L( reduced ) = L( full )

2 ln( L( reduced )) [ 2 ln( L( full ))] ~ 2 p

Interpretation of Estimated Coefficients in Odds and Probabilities: OR interpretation: ORexposure= e exp OR interpretation in the presence of interaction (two binary predictors): ORexposure/interacting factor present = e e + k + ek ORexposure/interacting factor absent = e e

e + e Probability interpretation: P(D/E) = 1 + e + e


SAS CODE:
proc logistic data = analysis; class YourPredictor_c (ref= "YourBaseline");
* automatic dummy coding to get >1 OR against the reference group;

model YourOutcome_c (event = "Yes") = YourPredictor / lackfit;


*lackfit gives Hosmer and Lemeshow goodness of fit chi-square test;

output out = OutDataSet p = Predicted; run;


*outputs predicted probabilities to new dataset;

Pair-Matched Data Binary Predictor Binary Outcome

Pair-Matched Data
Case Exposed Unexposed Odds Ratio Matched-control Exposed Unexposed a b c d

OR =

b c

McNemars Test H0: exposure and disease are independent Test Statistic:

(b c) 2 ~ 12 b+c
1:M Matched Data Conditional Logistic Regression:
e ORinterpretation: 1 )exposure= e exp OR c l( ) = ( )b x (
e

Matched Data Unrestricted Predictors and Covariates Binary Outcome

The simplest likelihood (from 2x2):


1 + e e 1 + e e

SAS CODE:** SAS V9 ONLY

proc logistic data = yourData ; model YourOutcpme_c (event= "Yes") = YourPredictor1 YourPredictor2 YourPredictor3...; strata MatchingVariable1 MatchingVariable2 / info; output out = OutDataset p = Predicted; run;

vi

You might also like