## 5.1 2x2 Tables

We wish to investigate whether attending a creche is associated with having had a lower respiratory tract infection.

This dataset contains socioeconomic status information in the variable ‘socio’, information on whether an individual was cared for at home (no) or attends a creche (Yes) in the variable ‘creche’ and whether in the past year an individual had had a respiratory infetion in the variable ‘lrti’. Note that these variables are coded as factors - R’s way of coding categorical variables.

The key commands here are cc() and tabpct() from epiDisplay. As we’ve seen, the cc() function conducts some hypothesis tests and extracts an OR, while tabpct() generates row and column percentages. To assess the strength of evidence for an association between lower respiratory tract infection and creche attendance, we can look at the result of the $$\chi^2$$ test.

#--- Get a 2x2 table with percentages
creche %$% tabpct(lrti, creche, graph = F) ## ## Original table ## creche ## lrti No Yes Total ## No 499 62 561 ## Yes 53 27 80 ## Total 552 89 641 ## ## Row percent ## creche ## lrti No Yes Total ## No 499 62 561 ## (88.9) (11.1) (100) ## Yes 53 27 80 ## (66.2) (33.8) (100) ## ## Column percent ## creche ## lrti No % Yes % ## No 499 (90.4) 62 (69.7) ## Yes 53 (9.6) 27 (30.3) ## Total 552 (100) 89 (100) #--- Get a 2x2 table with totals, tests and an OR creche %$% cc(lrti, creche, graph = F)
##
##        creche
## lrti     No Yes Total
##   No    499  62   561
##   Yes    53  27    80
##   Total 552  89   641
##
## OR =  4.1
## 95% CI =  2.41, 6.99
## Chi-squared = 30.17, 1 d.f., P value = 0
## Fisher's exact test (2-sided) P value = 0

Exercise 13.1: Is there an association between creche attendance and lower respiratory tract infection?