## 5.2 Confounding by SES

Lower respiratory tract infection is strongly related to socioeconomic status (SES). If creche attendance is also related to SES we might expect confounding from SES to impact the association between lower respiratory tract infection and socioeconomic status.

To handle this confounding, we can analyse the association separately within strata defined by the confounder (stratification).

Exercise 13.2: Use the cc() command to determine if:

1. creche attendance is associated with SES and
1. lower respiratory tract infection is associated with SES. What do you conclude about confounding?

We can examine the 2x2 tables by group by filtering the dataset to the stratum we wish to investigate and then using the tabpct command. The filter() command comes from dplyr (in the tidyverse) and is used to select rows in the dataset meeting a certain condition. Note the chaining of two types of pipes here. We restrict the dataset first, then put it into the function we want to use second.

#--- Look at association between LRTI and Creche by strata of SES
creche %>% filter(socio == "Average SES") %$% tabpct(lrti, creche, graph = F) ## Warning: package 'bindrcpp' was built under R version 3.5.3 ## ## Original table ## creche ## lrti No Yes Total ## No 468 57 525 ## Yes 19 8 27 ## Total 487 65 552 ## ## Row percent ## creche ## lrti No Yes Total ## No 468 57 525 ## (89.1) (10.9) (100) ## Yes 19 8 27 ## (70.4) (29.6) (100) ## ## Column percent ## creche ## lrti No % Yes % ## No 468 (96.1) 57 (87.7) ## Yes 19 (3.9) 8 (12.3) ## Total 487 (100) 65 (100) creche %>% filter(socio == "Very low SES") %$% tabpct(lrti, creche, graph = F)
##
## Original table
##        creche
## lrti     No  Yes  Total
##   No     31    5     36
##   Yes    34   19     53
##   Total  65   24     89
##
## Row percent
##      creche
## lrti       No     Yes  Total
##   No       31       5     36
##        (86.1)  (13.9)  (100)
##   Yes      34      19     53
##        (64.2)  (35.8)  (100)
##
## Column percent
##        creche
## lrti     No       %  Yes       %
##   No     31  (47.7)    5  (20.8)
##   Yes    34  (52.3)   19  (79.2)
##   Total  65   (100)   24   (100)

Exercise 13.3: What percentage of children attending a creche had lower respiratory tract infection if they were from a higher SES? A lower SES?

While the cc() command calculates the odds ratio for you, it is useful to note that in R you can simply do this ‘by hand’. There is no need to use the display command like in Stata.

#--- Get the 2x2 table
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
#--- Calculate the odds and odds ratio 'by hand'
27/62 # odds of LRTI in creche goers
## [1] 0.435
53/499 # odds of LRTI in creche goers
## [1] 0.106
(27/62)/(53/499) # OR
## [1] 4.1
(499*27)/(62*53) # Alternate calculation of OR
## [1] 4.1