-
Notifications
You must be signed in to change notification settings - Fork 48
/
fittingIomModels.Rmd
245 lines (162 loc) · 6.45 KB
/
fittingIomModels.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
---
title: "Modeling Vitamin D Serum Level as a Function of Intake"
author: "Keith Baggerly"
date: "July 16, 2016"
output: pdf_document
---
# Executive Summary
## Introduction
In 2010, the Institute of Medicine (IOM) released a report updating the Dietary Reference Intake (DRI) values for vitamin D and calcium. In an earlier report, we described our own independent assembly of the raw values. Here, we describe our attempts to (1) fit models to the data relating total vitamin D intake (TI, diet + supplement) to achieved serum level (SL), and to (2) identify a RDA supplement value for most of the population to reach a serum level adequate for benefit.
## Data and Methods
We use the table of data values, vitD.RData, we assembled in our previous report.
Following the IOM report (add page number and quote here), we fit linear mixed effect (LME) values of the form
SL = b*(log(TI) + random effect by study) + noise
We use the R package lme4 to fit models for
* all studies
* only studies with young participants
* only studies with adult participants
* only studies with old participants
We plotted the data using color and symbol to indicate study and age group respectively, and superimposed confidence intervals.
## Results
Our model fits differ slightly from those reported by the IOM.
*Need to list our results by fit here*
Further, these fits show clearly that the confidence intervals used by the IOM are based on the standard errors of the mean for all studies, and not on the overall standard deviation. Thus, the confidence intervals are too narrow by roughly a factor of 3 solely in terms of the random effect, and would need to be wider yet to allow for variation between individual participants within a study.
## Conclusions
The IOM's RDA is is too low by roughly an order of magnitude.
# Load Data and Libraries
We begin by loading the data and libraries we need for this report.
```{r loadData}
library(lme4)
vitD <- read.csv("iomReview.csv")
vitD <- vitD[!is.na(vitD[,"N"]),]
```
# Plot Data
Next, we plot the data as presented in the IOM report.
```{r plotDataAsPresented}
plot(vitD[,"IOMIntake"],
vitD[,"IOMLevel"],
pch=vitD[,"PlotSymbol"],
bg=as.character(vitD[,"Color"]), cex=2,
xlab="Vit D Intake in IU",
ylab="Serum 25(OH)D in nmol/L",
main="Data from Studies Used for\nIOM Vit D Review, 2010",
ylim=c(0,110))
```
Next, we plot the data after log-transforming the x-values, as was done for modeling purposes.
```{r plotDataWLog}
plot(log(vitD[,"TotalIntake"]),
vitD[,"AchievedLevel"],
pch=vitD[,"PlotSymbol"],
bg=as.character(vitD[,"Color"]), cex=2,
xlab="Log(Vit D Intake in IU)",
ylab="Serum 25(OH)D in nmol/L",
main="Studies Used by IOM Vit D Review, 2010",
xlim=c(0,8), ylim=c(0,110))
```
# Fit Models
Now we fit linear mixed effect models of the form specified in the IOM report. Since some of the values we found didn't precisely match those in the IOM report, we have fit the models both with the data we think the IOM used (taken from their Table 5.4) and with the data we think should apply.
## Fitting All Studies
```{r fitLme}
library(lme4)
vitDModel <-
lmer(AchievedLevel ~ -1 + log(TotalIntake) +
(-1 + log(TotalIntake)|Study),
data=vitD)
vitDModelIom <-
lmer(IOMLevel ~ -1 + log(IOMIntake) +
(-1 + log(IOMIntake)|Study),
data=vitD)
summary(vitDModel)
summary(vitDModelIom)
```
## Fitting Studies Involving Young Participants
```{r fitYoung}
vitDYoung <-
lmer(AchievedLevel ~ -1 + log(TotalIntake) +
(-1 + log(TotalIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Young",])
vitDYoungIom <-
lmer(IOMLevel ~ -1 + log(IOMIntake) +
(-1 + log(IOMIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Young",])
summary(vitDYoung)
summary(vitDYoungIom)
```
## Fitting Studies Involving Adult Participants
```{r fitAdult}
vitDAdult <-
lmer(AchievedLevel ~ -1 + log(TotalIntake) +
(-1 + log(TotalIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Adult",])
vitDAdultIom <-
lmer(IOMLevel ~ -1 + log(IOMIntake) +
(-1 + log(IOMIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Adult",])
summary(vitDAdult)
summary(vitDAdultIom)
```
## Fitting Studies Involving Old Participants
```{r fitOld}
vitDOld <-
lmer(AchievedLevel ~ -1 + log(TotalIntake) +
(-1 + log(TotalIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Old",])
vitDOldIom <-
lmer(IOMLevel ~ -1 + log(IOMIntake) +
(-1 + log(IOMIntake)|Study),
data=vitD[vitD[,"Age.Group"]=="Old",])
summary(vitDOld)
summary(vitDOldIom)
```
## Estimating Individual Dataset Slopes
```{r estimateSlopes}
studyNames <- levels(vitD[,"Study"])
studyNames <- studyNames[studyNames != ""]
nStudies <- length(studyNames)
studySlopes <- rep(0, nStudies)
names(studySlopes) <- studyNames
for(i1 in 1:nStudies){
tempModel <- lm(AchievedLevel ~ -1 + log(TotalIntake),
data=vitD[vitD[,"Study"]==studyNames[i1],])
studySlopes[studyNames[i1]] <- tempModel[["coefficients"]]
}
```
## Plot Data with CIs
Next, we plot the data with CIs reported by the IOM. These add/subtract twice the "Std. Error" values as reported by the
data summary.
```{r plotDataWithCIs}
plot(vitD[,"IOMIntake"],
vitD[,"IOMLevel"],
pch=vitD[,"PlotSymbol"],
bg=as.character(vitD[,"Color"]), cex=2,
xlab="Vit D Intake in IU",
ylab="Serum 25(OH)D in nmol/L",
main="Data from Studies Used for\nIOM Vit D Review, 2010",
ylim=c(0,110))
ciX <- seq(from=1, to=2400, by=1)
lines(ciX, 9.613*log(ciX))
lines(ciX, (9.613 - 2*0.6392)*log(ciX), lty="dashed")
lines(ciX, (9.613 + 2*0.6392)*log(ciX), lty="dashed")
abline(h=50)
abline(v=600)
```
Next, we plot the data also using the CIs we think should apply. These add/subtract twice the "Std. Dev." values as reported by the
data summary.
```{r plotDataWithRightCIs}
plot(vitD[,"IOMIntake"],
vitD[,"IOMLevel"],
pch=vitD[,"PlotSymbol"],
bg=as.character(vitD[,"Color"]), cex=2,
xlab="Vit D Intake in IU",
ylab="Serum 25(OH)D in nmol/L",
main="Data from Studies Used for\nIOM Vit D Review, 2010",
ylim=c(0,110))
ciX <- seq(from=1, to=2400, by=1)
lines(ciX, 9.613*log(ciX))
lines(ciX, (9.613 - 2*0.6392)*log(ciX), lty="dashed")
lines(ciX, (9.613 + 2*0.6392)*log(ciX), lty="dashed")
lines(ciX, (9.613 - 2*1.927)*log(ciX), lty="dashed", col="red")
lines(ciX, (9.613 + 2*1.927)*log(ciX), lty="dashed", col="red")
abline(h=50)
abline(v=600)
```