-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.Rmd
More file actions
129 lines (103 loc) · 3.51 KB
/
index.Rmd
File metadata and controls
129 lines (103 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
title: "Assessing interation in epidemiological studies"
author: "Ehsan Karim, ehsan.karim@ubc.ca, https://ehsank.com/"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [ref.bib]
description: |
Interactions and effect modifications.
link-citations: yes
github-repo: ehsanx/interaction
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
require(SASxport)
require(DiagrammeR)
require(DiagrammeRsvg)
require(rsvg)
library(magrittr)
library(svglite)
library(png)
require(nhanesA)
require(survey)
require(Publish)
require(knitr)
require(jtools)
require(interactions)
require(interactionR)
require(mosaic)
require(epiR)
cache.ON = TRUE
```
# Definitions
## Effect modification
Causal effect of exposure (A) on outcome (Y) depends upon levels of a third factor (B). This is the scenario when the exposure-outcome association differs within the strata of a 2nd exposure (2nd exposure = effect modifier). Interaction term is often added on a logistic regression model to assess the impact.
```{r dagem, echo=FALSE, fig.cap="An illustration of possible effect modification by a dichotomous factor $B$ (tobacco smoking [**smk**]) while investigating the impact of a dichotomous factor $A$ (alcohol [**alc**]) on the dichotomous outcome $Y$ (oral cancer [**oc**]).\\label{fig:dagem}", out.width = '50%'}
knitr::include_graphics("images/dagem.png")
```
## Interaction
Causal effect of combination of multiples exposures (A and B) on outcome (Y). Interaction is the joint causal effect of two exposures on an outcome.
```{r dag, echo=FALSE, fig.cap="An illustration of possible interaction by while investigating the impact of two dichotomous factors: $A$ (alcohol [**alc**]) and $B$ (tobacco smoking [**smk**]) on the dichotomous outcome $Y$ (oral cancer [**oc**]).\\label{fig:dag}", out.width = '50%'}
knitr::include_graphics("images/dag.png")
```
## Example data
**Data source**: @rothman1972effect
```{r}
require(interactionR)
data(OCdata)
dim(OCdata)
summary(OCdata)
```
Variables
- **oc**, oral cancer, outcome (Y)
- **alc**, alcohol use, first exposure (A)
- **smk**, smoking, second exposure (B)
```{r}
outcome = "oc"
ex = "alc"
dataset = OCdata
M <- table(dataset[[ex]], dataset[[outcome]])
rownames(M) <- c("Exposure -", "Exposure +")
colnames(M) <- c("Outcome -", "Outcome +")
M
```
### Crude risk ratio
```{r}
require(mosaic)
relrisk(M, verbose = TRUE)
```
### Change exposure label if RR <1
This step is not necessary of RR > 1. The following calculattion assumes that exposure and stratification factors are risk factors for the outcome (RR > 1), not protective factors. If protective, estimates of RERI and AP will be invalid, although the estimate of SI is not affected by this condition.
```{r}
M3 <- matrix(c(M[2,2],M[2,1],M[1,2],M[1,1]), nrow = 2, byrow = TRUE)
require(epiR)
```
### Get detailed estimates from 2x2 table
```{r}
require(epiR)
res <- epi.2by2(dat = M3, method = "cross.sectional",
conf.level = 0.95, units = 1,
interpret = FALSE,
outcome = "as.columns")
res
```
Check the results yourself
```{r}
p1 <- as.numeric(strsplit(as.character(res$tab$` Prevalence *`), " ")[[1]][1])
p0 <- as.numeric(strsplit(as.character(res$tab$` Prevalence *`), " ")[[2]][1])
RR <- p1/p0
RR
RD <- p1 - p0
RD
OR <- (p1/(1-p1))/(p0/(1-p0))
OR
```
## Further reading
Useful references
- @vanderweele2009distinction,
- @vanderweele2011interpretation,
- @rothman2012epidemiology,
- @vanderweele2014tutorial,
- @bours2021tutorial,
- @whitcomb2023interaction