5 Stratified Analysis of 2x2 Tables: Practical 13

In this practical we look at stratified analysis of 2x2 tables to analyse the association between two binary variables in the presence of a confounding variable.

As always, we commence by loading the appropriate libraries, changing any options, and reading in the dataset. This time we have added the library vcdExtra (to mimic Stata’s expand command). Remember to first install any packages that you need.

#--- Load libraries
library(epiDisplay)
library(foreign)
library(psych)
library(magrittr)
library(vcdExtra)
library(tidyverse)

#--- Change to show no scientific notation & round to 3 decimal places
options(scipen = 10, digits=3) 

#--- Set the plot theme to come out in black and white
theme_set(theme_bw())

#--- Read in the file
creche <- read.dta("./CRECHE.dta", convert.factors = T)