# NOT RUN {
### Example from Essential Medical Statistics
# Page 178, Chapter 18: Controlling for confounding: Stratification
lepto <- expandtbl(
male = c(36, 14, 50, 50), female = c(24, 126, 10, 90),
exp_name = "area", exp_lvl = c("Rural", "Urban"),
case_name = "ab", case_lvl = c("Yes", "No"),
strata_name = "gender"
)
## label variables and data
lepto <- label(lepto, "Prevalence survey of leptospirosis in West Indies")
lepto <- label(lepto, area="Type of area", ab = "Leptospirosis Antibodies",
gender="Gener: Male or Female")
## Calculate RR
mhrr(lepto, area, ab)
## Calculate MHRR
mhrr(lepto, area, ab, gender)
# }
# NOT RUN {
### Demonstration: Calculating Risk Ratios
## Essential Medical Statistics, Betty R. Kirkwood, Second Edition
## Chapter 16, Table 16.4, Page 154
## For Risk Ratio
lung <- expandtbl(
c(39, 29961, 6, 59994),
exp_name = "smoking",
exp_lvl = c("Smokers", "Non-smokers"),
case_name = "cancer",
case_lvl = c("Yes", "No")
)
## label variable and dataset
lung <- labelVar(lung, smoking="Yes or No", cancer="Yes or no")
lung <- labelData(lung, "Follow up lung cancer study")
## check dataset
codebook(lung)
## calculate RR
mhrr(lung, smoking, cancer, exp_value = "Smokers", case_value = "Yes")
## Simpson's paradox
## Burt Gerstman's Epidemiology, page 326, table 14.1
simpson <- expandtbl("1" = c(1000, 9000, 50, 950),
"2" = c(95, 5, 5000, 5000),
exp_name = "trt",
exp_lvl = c("new", "standard"),
case_name = "case",
case_lvl = c("alive", "dead"),
strata_name = "clinic")
## calculate RR
mhrr(simpson, trt, case, exp_value = "new", case_value = "alive")
## calculate MH RR
mhrr(simpson, trt, case, clinic)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab