-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculatingCombinedGAM.Rmd
306 lines (220 loc) · 10.3 KB
/
calculatingCombinedGAM.Rmd
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
---
title: Notes on calculating combined GAM estimates within the Rapid Assessment Method (RAM)
author: "Mark Myatt"
date: "15 February 2020" #'`r format(Sys.Date(), "%d %B %Y")`'
fontsize: 12pt
geometry: margin=2cm
documentclass: article
classoption: a4paper
bibliography: bibliography.bib
lot: FALSE
lof: FALSE
link-citations: TRUE
links-as-notes: FALSE
colorlinks: TRUE
linkcolor: blue
citecolor: blue
urlcolor: blue
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
warning = FALSE,
message = FALSE)
if(!require(ggplot2)) install.packages("ggplot2")
if(!require(magrittr)) install.packages("magrittr")
themeSettings <- theme_bw() +
theme(panel.border = element_rect(colour = "#993300",
size = 0.5),
panel.grid.major = element_line(linetype = 1,
size = 0.2,
colour = "gray90"),
panel.grid.minor = element_line(linetype = 0),
strip.background = element_rect(colour = "#993300",
fill = "#993300"),
strip.text = element_text(colour = "white"),
legend.key = element_rect(linetype = 0),
axis.text.x = element_text(size = 10),
axis.text.y = element_text(size = 10),
axis.ticks = element_line(colour = "#993300", size = 0.5))
```
\newpage
# Background
A June 2019 article in Field Exchange advocates for the reporting of combined GAM estimate (i.e., a single prevalence estimate for GAM cases identified by WHZ and by MUAC). By January 2020, the SMART ENA software has included the calculation and reporting of this single GAM prevalence estimate.
This document reports on our current thining on how this single prevalence estimate can be calculated within the Rapid Assessment Method (RAM). Additionally, we explore how oedema cases can also be added in calculating this single GAM prevalence estimate.
# Proposed approach
PROBIT gives a probability so we look to combining two probabilities:
$$ P(GAM_{\text{MUAC}} ~ \cup ~ GAM_{\text{WHZ}}) ~ = ~ P(GAM_{\text{MUAC}}) ~ + ~ P(GAM_{\text{WHZ}}) $$
However, the problem is that we do not have `independent` probabilities. We overestimate because the intersection gets counted twice. Therefore we need:
$$ P(GAM_{\text{MUAC}} ~ \cup ~ GAM_{\text{WHZ}}) ~ = ~ P(GAM_{\text{MUAC}}) ~ + ~ P(GAM_{\text{WHZ}}) ~ - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}}) $$
We have the first two terms but not the third. We can estimate the third term from a 2 by 2 table:
```{r twoByTwo, echo = FALSE, eval = TRUE}
twoByTwo <- data.frame(rbind(c("a", "b"), c("c", "d")))
row.names(twoByTwo) <- c("$\\text{MUAC} < 125$", "$\\text{MUAC} \\geq 125$")
knitr::kable(x = twoByTwo,
booktabs = TRUE,
row.names = TRUE,
col.names = c("$\\text{WHZ} < -2$", "$\\text{WHZ} \\geq -2$"),
align = "c",
escape = FALSE,
format = "latex") %>%
kableExtra::kable_styling(latex_options = c("striped", "HOLD_position"),
font_size = 12) %>%
kableExtra::row_spec(row = 0, bold = TRUE) %>%
kableExtra::row_spec(row = 1:2, monospace = TRUE) %>%
kableExtra::column_spec(column = 1:3, monospace = TRUE) %>%
kableExtra::column_spec(column = 1, bold = TRUE)
```
and
$$ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}}) ~ = ~ \frac{a}{a ~ + ~ b ~ + ~ c ~ + ~ d} $$
We have a small sample size so the estimate will lack precision but I think that being "clever" and using something like:
$$ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}}) ~ = ~ P(GAM_{\text{MUAC}}) ~ \times ~ P(GAM_{\text{WHZ}}) $$
will not work as it assumes independence.
We can try to move forward with this hybrid method.
\newpage
# Worked example for combined GAM by WHZ and GAM by MUAC
We try the proposed approach in R using a dataset from Uganda.
```{r example1, echo = TRUE, eval = TRUE}
## Read dataset from Uganda
x <- read.table(file = "data/ugan01.csv", header = TRUE, sep = ",")
## First 10 rows of the Uganda dataset
```
```{r example1a, echo = FALSE, eval = TRUE}
head(x, 10)
```
We then create case definitions as follows:
```{r example2, echo = TRUE, eval = TRUE}
## Case definitions
x$gamWHZ <- ifelse(x$whz < -2, 1, 2) ## GAM by WHZ
x$gamMUAC <- ifelse(x$muac < 125, 1, 2) ## GAM by MUAC
x$cGAM <- ifelse(x$whz < -2 | x$muac < 125, 1, 2) ## GAM by WHZ and MUAC
## First 10 rows of the updated Uganda dataset contining case definitions
```
```{r example2a, echo = FALSE, eval = TRUE}
head(x, 10)
```
## Combined GAM estimation using the classical approach
Calculating for prevalence using the classical approach we get:
```{r example3, echo = TRUE, eval = TRUE}
## Classic prevalence for GAM by MUAC
round(prop.table(table(x$gamMUAC))[1] * 100, 2)
## Classic prevalence for GAM by WHZ
round(prop.table(table(x$gamWHZ))[1] * 100, 2)
## Classic prevalence for GAM by WHZ and MUAC
round(prop.table(table(x$cGAM))[1] * 100, 2)
```
We can test whether GAM cases by MUAC and GAM cases by WHZ are independent.
```{r example4, echo = TRUE, eval = FALSE}
## Test if the two case definitions are independent
chisq.test(table(x$gamMUAC, x$gamWHZ))
```
The chi-square test has a *p-value* of `r chisq.test(table(x$gamMUAC, x$gamWHZ))$p.value` indicating that the two case definitions are not independent.
\newpage
## Combined GAM estimation using proposed hybrid approach
We then proceed with our proposed hybrid approach using simple PROBIT prevalence estimation.
```{r example6, echo = TRUE, eval = TRUE}
## Simple PROBIT prevalence for GAM by MUAC
pMUAC <- pnorm(125, mean(x$muac), sd(x$muac))
```
```{r example6a, echo = FALSE, eval = TRUE}
round(pMUAC * 100, 2)
```
```{r example7, echo = TRUE, eval = TRUE}
## Simple PROBIT prevalence for GAM by WHZ
pWHZ <- pnorm(-2, mean(x$whz), sd(x$whz))
```
```{r example7a, echo = FALSE, eval = TRUE}
round(pWHZ * 100, 2)
```
```{r example8, echo = TRUE, eval = TRUE}
## Estimate the UNION probability
pUNION <- table(x$gamMUAC, x$gamWHZ)[1,1] / sum(table(x$gamMUAC, x$gamWHZ))
```
```{r example8a, echo = FALSE, eval = TRUE}
round(pUNION * 100, 2)
```
```{r example9, echo = TRUE, eval = TRUE}
## Estimate of GAM by MUAC and WHZ by PROBIT
round((pMUAC + pWHZ - pUNION) * 100, 2)
```
\newpage
# Extending the approach to include oedema cases
Using the same concepts, we can extend the approach to include oedema cases. For this we need to take into account not only the intersection between GAM by MUAC and GAM by WHZ but also the intersection of GAM by MUAC and oedema cases, the intersection of GAM by WHZ and oedema cases, and the intersection between GAM by MUAC, GAM by WHZ and oedema cases as follows:
$$\begin{aligned}
P(GAM_{\text{MUAC}} ~ \cup ~ & GAM_{\text{WHZ}} ~ \cup ~ SAM_{\text{oedema}}) ~ = \\
& P(GAM_{\text{MUAC}}) ~ + ~ P(GAM_{\text{WHZ}}) ~ + ~ P(SAM_\text{oedema}) \\
~ & - ~ [P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}}) ~ - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}})] \\
~ & - ~ [P(GAM_{\text{MUAC}} ~ \cap ~ SAM_{\text{oedema}}) ~ - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}})] \\
~ & - ~ [P(GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}}) ~ - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}})] \\
~ & - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}})
\end{aligned}$$
Simplifying this we get:
$$\begin{aligned}
P(GAM_{\text{MUAC}} ~ \cup ~ & GAM_{\text{WHZ}} ~ \cup ~ SAM_{\text{oedema}}) ~ = \\
& P(GAM_{\text{MUAC}}) ~ + ~ P(GAM_{\text{WHZ}}) ~ + ~ P(SAM_\text{oedema}) \\
~ & - ~ P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}}) \\
~ & - ~ P(GAM_{\text{MUAC}} ~ \cap ~ SAM_{\text{oedema}} \\
~ & - ~ P(GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}}) \\
~ & + ~ (2 \times P(GAM_{\text{MUAC}} ~ \cap ~ GAM_{\text{WHZ}} ~ \cap ~ SAM_{\text{oedema}}))
\end{aligned}$$
# Worked example for combined GAM by WHZ, GAM by MUAC and oedema
We try the proposed approach in R using the same dataset from Uganda used in the previous example. We already have an oedema variable that is coded into 1 for an oedema case and 2 for a non-oedema case. We just need to re-define the `cGAM` variable to include oedema cases.
\newpage
```{r example10, echo = TRUE, eval = TRUE}
## Case definition for combined GAM including oedema cases
x$cGAM <- ifelse(x$whz < -2 | x$muac < 125 | x$oedema == 1, 1, 2)
## First 10 rows of the updated Uganda dataset contining case definitions
```
```{r example10a, echo = FALSE, eval = TRUE}
head(x, 10)
```
## Combined GAM estimation using the classical approach
Calculating for oedema and combine GAM prevalence using the classical estimator we get:
```{r example11, echo = TRUE, eval = TRUE}
## Classic prevalence for oedema cases
round(prop.table(table(x$oedema))[1] * 100, 2)
## Classic prevalence for GAM by WHZ and MUAC and oedema cases
round(prop.table(table(x$cGAM))[1] * 100, 2)
```
## Combined GAM estimation using proposed hybrid approach
We then proceed with our proposed hybrid approach using simple PROBIT prevalence estimation to include oedema cases.
```{r example12, echo = TRUE, eval = TRUE}
## Estimate the probability of oedema cases
pOedema <- prop.table(table(x$oedema))[1]
```
```{r example13, echo = TRUE, eval = TRUE}
## Estimate union probability for WHZ and oedema
pOedemaWHZ <- table(x$gamWHZ, x$oedema)[1,1] / sum(table(x$gamWHZ, x$oedema))
```
```{r example13a, echo = FALSE, eval = TRUE}
round(pOedemaWHZ * 100, 2)
```
```{r example14, echo = TRUE, eval = TRUE}
## Estimate union probability for MUAC and oedema
pOedemaMUAC <- table(x$gamMUAC, x$oedema)[1,1] / sum(table(x$gamMUAC, x$oedema))
```
```{r example14a, echo = FALSE, eval = TRUE}
round(pOedemaMUAC * 100, 2)
```
```{r example15, echo = TRUE, eval = TRUE}
## Create variable for GAM meeting WHZ, MUAC and oedema criteria
x$gamUnion <- ifelse(x$oedema == 1 & x$gamWHZ == 1 & x$gamMUAC == 1, 1, 2)
## Estimate union probability for MUAC, WHZ and oedema
pGAMunion <- prop.table(table(x$gamUnion))[1]
```
```{r example15a, echo = FALSE, eval = TRUE}
round(pGAMunion * 100, 2)
```
```{r example16, echo = TRUE, eval = TRUE}
## Estimate combined GAM including oedema cases
round((pMUAC + pWHZ + pOedema - pUNION - pOedemaWHZ -
pOedemaMUAC + (2 * pGAMunion)) * 100, 2)
```