-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stratified.qmd
116 lines (81 loc) · 6.75 KB
/
Stratified.qmd
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
---
title: "Stratified analysis"
editor: visual
---
## 1. Learning outcomes
At the end of the session, participants will be able to:
- Consider the effect of confounding and effect modification on the association between exposure and disease,
- Perform stratified analysis using the Mantel-Haenszel approach
*The use of stratified analysis, is the first step to identify confounding factors and effect modifiers one by one (after, of course, thinking which variables could potentially be confounders or effect modifiers). As the final step, you will be using Regression Models to account for confounding and check for effect modification. We will see these with you in the Multivariable Module (MVA), next year.*
## 2. Story/plot description
From the univariable analysis, it seems that eating orzpo and eating moussaka as well as drinking champagne are associated with the highest risk of becoming ill. There are, however, many other food items that are associated with an increased risk (even if not statistically significant).
You should next think about potential confounders and about effect modification. Think about which variables you might want to check for effect modification or confounding. One common strategy is to base this decision on the results obtained in the univariable analysis and a p-value threshold of 0.20-0.25. Also, food items that are known risk factors for gastroenteritis could also be included regardless of their univariable p-value.
## 3. Questions/Assignments
## 3.1. Confounders and effect modification
Discuss how to identify potential confounders and effect modification. Draw dummy tables before coding to have clear what you want to achieve.
## 3.2. Install packages and load libraries
```{r}
# Load the required libraries into the current R session:
pacman::p_load(rio,
here,
tidyverse,
skimr,
plyr,
janitor,
lubridate,
gtsummary,
flextable,
officer,
epikit,
apyramid,
scales,
EpiStats)
```
## 3.3. Import your data
```{r, Import_data}
# Import the raw data set:
copdata <- rio::import(here::here("data", "Spetses_clean2_2024.rds"))
```
## 3.4. Consider and assess for confounding and/or effect modification
Have a look at the relative risk for being a case having eaten a specific food item (for example, moussake), when stratified by another variable (for example, orzo). You may consider stratifying by orzo, as it has the highest RR in the univariable analysis.
There are many variables in this dataset and it might not make sense to stratify each variable by each other variable on our search for effect modifiers and confounders.
However, we also don't want to be too restrictive as a variable which actually (i.e. causally) is associated with the outcome might not show a significant association at the significant level we decided (say 5%) in the univariable analysis due to confounding. Therefore, we could test all variables statistically significant at the 15%, 20%, or 25% level (specific percentage to be decided by your group). In our solutions here, we are looking at moussaka and champagne, stratified by orzo, but you may decide to look at other food items as well.
::: {.callout-tip title="Need a little bit of help?" collapse="true"}
Use the function `csinter()` of the EpiStats package.
:::
### a) Moussaka as exposure of interest, stratified by having eaten orzo
If we stratify the **effect of moussaka by orzo** we ask the question: does eating orzo modify or confound the association between eating moussaka and being a case?
```{r}
stratall <- copdata %>%
# Mutate across to convert cases to numeric:
mutate(across(.cols = case,
.fns = ~ as.numeric(.)))
# Pass data to the csinter function:
orzostrata <- csinter(x = stratall,
cases = "case",
exposure = "moussaka",
by = "orzo")
orzostrata
```
Let's check if orzo is associated with moussaka (if we are thinking moussaka may be a confounder, we need to see if there is an association between the potential confounder (moussaka) and the exposure (orzo)):
```{r}
# Perform Wilcoxon rank sum test on orzo and moussaka:
wilcox.test(orzo ~ moussaka,
data = copdata)
```
### b) Champagne as exposure of interest, stratified by having eaten orzo
```{r}
# Pass data to the csinter function:
champstrata <- csinter(x = stratall,
cases = "case",
exposure = "champagne",
by = "orzo")
```
::: {.callout-warning title="Let's stop and... think!" collapse="true"}
Are there any indications to make you think there may be effect modification and/or confounding?
:::
We could stratify by orzo (the strongest risk factor in the univariable analysis), to examine if orzo confounds the association between eating moussaka and being a case. Before stratification, we will need to check if orzo meets the conditions of being a confounder. For a variable to be a confounder it needs to be associated both with the outcome (being a case) and with the exposure (and not be in the causal pathway between exposure and outcome). We know from univariable analysis that orzo is associated with being a case. If we run a Wilcoxon rank sum test, we will see that orzo is also associated with moussaka (indeed, you can see that most people either had both moussaka and orzo or neither of these food items, so they are associated with each other).
Above, we uses `ccinter` to stratify and save the object as "orzostrata".
orzostrata: Within the stratum of the people who ate orzo, moussaka has no significant effect (RR = 1.20, CI: 0.60 - 2.41). The same holds within the stratum of people who didn't eat orzo (RR = 1.05, CI = 0.38, 2.92). The adjusted MH-RR also suggests that moussaka has no effect (RRadj = 1.15, CI: 0.80 - 2.85). To identify confounding, we want to look at the % change between the crude and the adjusted RR. This is given by the csinter output "Adjusted/crude relative change". The difference between the crude and the MH-RR in this case is \>20% suggesting that orzo confounds the association between moussaka and the disease.
This result suggest that moussaka is not a risk factor of the disease and that the crude observed effect was due to the confounding effect of orzo.
If you stratify by moussaka, you see that moussaka does not confound the association between orzo and the disease. The same applies if you stratify the exposure to orzo by other variables. The above, the higher RR for orzo and the dose response relationship we found earlier for orzo (remember this was optional) provide additional evidence that there was something going on with the orzo with pesto dish!