In this vignette we explain how to use the model for children in R; we develop and explain the equations involved both for casual and advanced readers.
The main inputs for the body weight change model in children are:
Input | Meaning | Optional | Default |
---|---|---|---|
age |
Age (yrs) | No | - |
sex |
Either 'male' or 'female' |
No | - |
As an example consider a 7
year old 'female'
:
female_model1 <- child_weight(age = 7, sex = "female")
Furthermore, the model allows the user to input Fat and Fat Free Mass composition of the body:
Input | Meaning | Optional | Default |
---|---|---|---|
FM |
Fat Mass (kg) | Yes | Model estimate |
FFM |
Fat Free Mass (kg) | Yes | Model estimate |
For example, our female might have 19.9
kg of Fat Mass and 5.74
kg of Fat Free Mass:
female_model2 <- child_weight(age = 7, sex = "female", FM = 19.9, FFM = 5.74)
Energy intake can also be inputed as a vector of daily energy consumption:
Input | Meaning | Optional | Default |
---|---|---|---|
EI |
Energy Intake per day | Yes | Model estimate |
female_model3 <- child_weight(age = 7, sex = "female", FM = 19.9, FFM = 5.74,
EI = seq(1600, 1750, length.out = 365))
Note that in the examples above, EIchange = seq(1600, 1750, length.out = 365)
is inputed as a vector with each day representing the consumption reduction for that day. See Energy section for additional information.
Other (optional) inputs include:
Input | Meaning | Optional | Default |
---|---|---|---|
days |
Number of days to run de model | Yes | \(365\) |
dt |
Time step for Rungue-Kutta 4 | Yes | \(1\) |
checkValues |
Boolean indicating whether the model should check parameters make sense | Yes | TRUE |
All inputs used in the model are:
Input | Meaning | Optional | Default |
---|---|---|---|
age |
Age (yrs) | No | - |
sex |
Either 'male' or 'female' |
No | - |
FM |
Fat Mass (kg) | Yes | Model estimate |
FFM |
Fat Free Mass (kg) | Yes | Model estimate |
EI |
Energy Intake per day | Yes | Model estimate |
days |
Time period (days) to run the model | Yes | \(365\) |
dt |
Time step for Rungue-Kutta 4 | Yes | \(1\) |
checkValues |
Check for internal consistency | Yes | TRUE |
Finally, we remark that one can also input data from a database to estimate individual-level weight change (see the related section)
#Database information
ages <- c(8, 10, 7, 7, 12)
sexes <- c("male", "female", "female", "male", "male")
#Returns a weight change matrix and other matrices
database_model <- child_weight(ages, sexes)
Result plots can be obtained by model_plot
function:
model_plot(female_model2, "Body_Weight")
Plotting options include "Body_Weight"
, Fat_Mass
, and Fat_Free_Mass
. Several can be chosen at the same time:
model_plot(female_model2, c("Body_Weight", "Fat_Mass"))
Variables can also be plotted against age:
model_plot(female_model2, c("Body_Weight", "Fat_Mass"), timevar = "Age")
Energy intake is usually not continuously measured but measured at different and distant points in time (say 1 year apart). The function energy_build
allows the user to interpolate different energy models between the interpolation points. As an example consider an individual that initially consumed 1600
kcals, by day 365
consumed in 1750
kcals and by day 730
had increased his consumption to 1820
kcals. The energy_build
function interpolates those values via a Brownian Bridge:
EIbrownian <- energy_build(c(1600, 1750, 1820), c(0, 365, 730))
The interpolation looks like this:
ggplot() + geom_line(aes(x = 1:730, y = EI), data = data.frame(EI = EIbrownian)) +
theme_classic() +
xlab("Days") + ylab("Energy intake (kcals)") + ggtitle("Energy interpolation")
Such energy change matrix can be directly inputed in the model:
model_brownian <- child_weight(10, "male", EI = EIbrownian, days = 730)
Other interpolation modes include Linear
, Exponential
, Stepwise_R
(right stepwise), Stepwise_L
(left stepwise), and Logarithmic
:
EIlinear <- energy_build(c(1600, 1750, 1820), c(0, 365, 730), "Linear")
EIexponential <- energy_build(c(1600, 1750, 1820), c(0, 365, 730), "Exponential")
EIstepwise_r <- energy_build(c(1600, 1750, 1820), c(0, 365, 730), "Stepwise_R")
EIstepwise_l <- energy_build(c(1600, 1750, 1820), c(0, 365, 730), "Stepwise_L")
EIlogarithmic <- energy_build(c(1600, 1750, 1820), c(0, 365, 730), "Logarithmic")
Which look like this:
ggplot() +
geom_line(aes(x = 1:730, y = EI, color = "Brownian"),
data = data.frame(EI = EIbrownian)) +
geom_line(aes(x = 1:730, y = EI, color = "Linear"),
data = data.frame(EI = EIlinear)) +
geom_line(aes(x = 1:730, y = EI, color = "Exponential"),
data = data.frame(EI = EIexponential)) +
geom_step(aes(x = 1:730, y = EI, color = "Right Stepwise"),
data = data.frame(EI = EIstepwise_r)) +
geom_step(aes(x = 1:730, y = EI, color = "Left Stepwise"),
data = data.frame(EI = EIstepwise_l)) +
geom_line(aes(x = 1:730, y = EI, color = "Logarithmic"),
data = data.frame(EI = EIlogarithmic)) +
xlab("Days") + ylab("Energy change (kcals)") +
ggtitle("Energy interpolation") +
theme_classic() +
scale_color_manual("Interpolation",
values = c("Brownian" = "red", "Linear" = "deepskyblue3",
"Exponential" = "forestgreen", "Logarithmic" = "purple",
"Right Stepwise" = "black", "Left Stepwise" = "green"))
These models result in different weight changes:
model_linear <- child_weight(10, "male", EI = EIlinear, days = 730)
model_exponential <- child_weight(10, "male", EI = EIexponential, days = 730)
model_logarithmic <- child_weight(10, "male", EI = EIlogarithmic, days = 730)
model_stepwise_r <- child_weight(10, "male", EI = EIstepwise_r, days = 730)
model_stepwise_l <- child_weight(10, "male", EI = EIstepwise_l, days = 730)
Which look as follows:
richardsonparams
which is a list of parameters \(list(K = NA, Q = NA, B = NA, A = NA, nu = NA, C = NA)\) representing \(K, Q, \beta, A, \nu, C\). If parameters are specified, the model assumes the energy intake function is a generalized logistic function (Richardson’s function (Falkner and Tanner 2012)):
\[\begin{equation}
EI(t) = A + \frac{K-A}{(C + Q e^{-\beta \cdot t})^{1/\nu}}.
\end{equation}\]
girl <- child_weight(6,"female", days=365, dt = 5,
richardsonparams = list(K = 2700, Q = 10,
B = 12, A = 3, nu = 4,
C = 1))
## Using Richardson's function
model_plot(girl, "Body_Weight")
Vector data can also be used in the model to calculate weight change for several individuals at a time (which is quite faster than doing them individually). As an example consider the following dataset:
#Database information
mydata <- data.frame(
id = 1:5,
age = c(8, 10, 7, 7, 12),
sex = c("male", "female", "female", "male", "male"),
energy = runif(5, 1500, 2000),
prob = c(0.1, 0.2, 0.2, 0.05, 0.45))
#Get energy change with energy build function
eichange <- energy_build(cbind(runif(5, 1500, 2000), mydata$energy), c(0, 365))
#Returns a weight change matrix and other matrices
database_model <- child_weight(mydata$age, mydata$sex, EI = t(eichange))
Plots can also be obtained for the population with the same command model_plot
:
model_plot(database_model, "Body_Weight")
Summary measures can be obtained via model_mean
which quantifies mean for 'Body_Weight'
, 'Fat_Free_Mass'
, and 'Fat_Mass'
:
model_mean(database_model, "Body_Weight")
## time variable group mean SE_mean
## 1 0 Body_Weight 1 28.70000 3.478937
## 2 15 Body_Weight 1 28.60491 3.147901
## 3 30 Body_Weight 1 28.48989 2.876122
## 4 45 Body_Weight 1 28.35651 2.650648
## 5 60 Body_Weight 1 28.22731 2.463493
## 6 75 Body_Weight 1 28.10973 2.310368
Mean is only estimated for some points in time, to estimate mean for the whole period, consider changing the days
vector variable:
model_mean(database_model, "Body_Weight", days = 1:365)
## time variable group mean SE_mean
## 1 1 Body_Weight 1 28.69429 3.454706
## 2 2 Body_Weight 1 28.68851 3.430815
## 3 3 Body_Weight 1 28.68261 3.407301
## 4 4 Body_Weight 1 28.67666 3.384095
## 5 5 Body_Weight 1 28.67071 3.361162
## 6 6 Body_Weight 1 28.66444 3.338572
Mean can also be grouped by a variable (say, sex
):
model_mean(database_model, "Body_Weight", days = 1:365, group = mydata$sex)
## time variable group mean SE_mean
## 1 1 Body_Weight female 27.78152 4.587716
## 2 1 Body_Weight male 29.30280 4.838672
## 3 2 Body_Weight female 27.81281 4.551202
## 4 2 Body_Weight male 29.27230 4.809868
## 5 3 Body_Weight female 27.84355 4.515292
## 6 3 Body_Weight male 29.24198 4.781419
Finally, model_mean
can also be used to estimate survey
means using the svydesign
from the survey
package:
require("survey")
design <- svydesign(ids = ~id, probs = ~prob, data = mydata)
model_mean(database_model, group = mydata$sex, design = design)
## time variable group mean SE_mean
## 1 0 Age female 8.500000 1.1858541
## 2 0 Age male 7.655172 0.5772886
## 3 0 Fat_Free_Mass female 22.300000 3.2413346
## 4 0 Fat_Free_Mass male 21.468966 1.4274394
## 5 0 Fat_Mass female 5.450000 1.3834965
## 6 0 Fat_Mass male 3.286207 0.3756837
Additional information on the model for adults and other package functions can be obtained in the other package’s Vignettes
browseVignettes("bw")
EI
entry) or one can use a Richardson’s function (Falkner and Tanner 2012):
\[\begin{equation}
EI(t) = A + \frac{K-A}{(C + Q e^{-\beta \cdot t})^{1/\nu}}
\end{equation}\]
by specifying the individual’s parameters \(K,A,C,Q,\beta,\nu\). The energy expenditure is given by a combination of the changes in fat and fat free masses as well as the masses themselves:
\[\begin{equation}
\begin{aligned}
E & = \overbrace{K}_{\text{Individual's parameter}} + \overbrace{\gamma_{FFM} FFM}^{\text{Fat Free Mass}} + \overbrace{\gamma_{FM} FM}^{\text{Fat Mass}} + \overbrace{\beta \Delta I}^{\text{Difference in intake with respect to normal growth}} \\\\\\ & \qquad + \underbrace{\delta \cdot BW}_{\text{Body weight}} + \underbrace{\eta_{FFM} \cdot \dfrac{dFFM}{dt} + \eta_{FM} \cdot \dfrac{dFM}{dt}}_{\text{Changes in fat free and fat masses}},
\end{aligned}
\end{equation}\]
Thus body weight is the result of this physiological interdependencies between the fat mass, the fat free mass, the energy intake and the expenditure. The model is further expanded in the following section.
In particular, the body weight function (as a function of time \(t\)) depends on the individual’s sex (\(\textrm{Sex}\)), initial fat mass (\(FM_0\)), initial fat free mass (\(FFM_0\)), energy consumption function (\(EI(t)\)).
The components of body weight, \(FM\) and \(FFM\), are determined by a system of ordinary differential equations: \[\begin{equation}\label{diff} \begin{aligned} \rho_{FFM} \cdot \dfrac{d FFM}{dt} & = p \cdot (EI - E) + g \\\\ \rho_{FM} \cdot \dfrac{d FM}{dt} & = (1-p) \cdot (EI - E) - g \end{aligned} \end{equation}\]where \(p = C/(C + FM)\) a ratio established by Forbes with \(C = 10.4 \rho_{FFM} / \rho_{FM}\). The parameters \(\rho_{FM} = 9.4 kcal/g\) (\(= 9400 \textrm{ kcal}/\textrm{kg}\) and \(\rho_{FFM} = (4.3 \cdot FFM_0 + 837) \textrm{ kcal}/\textrm{kg}\) where \(FFM_0\) represents the amount of fat free mass (kg) at baseline.
The growth term is given by: \[\begin{equation}\label{growth} g:= g(t) = A e^{-(t - t_{A})/\tau_{A}} + B e^{-(t - t_{B})^2/2\tau_{B}^2} + D e^{-(t - t_{D})^2/2\tau_{D}^2}, \end{equation}\]where the parameters for each sex are given by table .
Energy expenditure in is given by: \[\begin{equation}\label{energy} E = K + \gamma_{FFM} FFM + \gamma_{FM} FM + \beta \Delta I + \delta \cdot BW + \eta_{FFM} \cdot \dfrac{dFFM}{dt} + \eta_{FM} \cdot \dfrac{dFM}{dt}, \end{equation}\]where \(K\) represents an energy expenditure constant determined by the initial energy balance (\(K = 800 \textrm{ kcal}/\textrm{d}\) for males; \(K = 700 \textrm{ kcal}/\textrm{d}\) for females); \(\beta = 0.24\) stands for the adaptation of energy expenditure when intake is perturbed \(\Delta I\); \(\eta_{FM} = 180 \textrm{ kcal}/\textrm{kg}\) and \(\eta_{FFM} = 230 \textrm{ kcal}/\textrm{kg}\) account for ``biochemical efficiencies associated to fat and protein synthesis’’ .
In particular, the function for physical activity \(\delta\) in is given by: \[\begin{equation} \delta(t) = \delta_{min} + \dfrac{(\delta_{max}-\delta_{min}) P^{h}}{t^h + P^h} \end{equation}\]with \(\delta_{min} = 10 \textrm{ kcal}/\textrm{kg}/\textrm{d}\) represents the average activity of young adults whilst \(\delta_{max}\) (\(\delta_{max} = 19 \textrm{ kcal}/\textrm{kg}/\textrm{d}\) and \(\delta_{max} = 17 \textrm{ kcal}/\textrm{kg}/\textrm{d}\) for males and females respectively) stands for the average physical activity for young children. The parameter \(P = 12 \textrm{ years}\) stands for the point of maximum physical activity whilst the constant \(h = 10\) represents the rate of decline as a function of age.
The perturbation of energy intake \(\Delta I\) represents the shift away from the intake associated to normal growth (\(\Delta I\) in ). It was estimated by: \[\begin{equation} \Delta I(t) = EI(t) - I_{ref}(t) \end{equation}\] where: \[\begin{equation}\label{iref} \begin{aligned} I_{ref}(t) & = EB_{ref} + K + (\gamma_{FFM} + \delta) FFM_{ref} + (\gamma_{FM} + \delta) FM_{ref} + \dfrac{\eta_{FFM}}{\rho_{FFM}} (p\cdot EB_{ref} + g) \\ & \qquad + \dfrac{\eta_{FM}}{\rho_{FM}} \big((1-p)\cdot EB_{ref} + g \big) \end{aligned} \end{equation}\] represents the reference energy intake for normal growth. The energy balance for reference children is also of the form: \[\begin{equation} EB_{ref}(t) = A e^{-(t - t^{EB}_{A})/\tau^{EB}_{A}} + B e^{-(t - t^{EB}_{B})^2/2(\tau^{EB}_{B})^2} + D e^{-(t - t^{EB}_{D})^2/2(\tau_{D}^{EB})^2}. \end{equation}\]The reference fat free mass \(FFM_{ref}\) and the reference fat mass \(FM_{ref}\) in were obtained from linear interpolations to the values in table which were obtained from (Ellis et al. 2000, Fomon et al. (1982), F. Haschke (1989)).
A closed form expression for the energy is given by: \[\begin{equation} E = \dfrac{K + (\gamma_{FFM} + \delta) FFM + (\gamma_{FM} + \delta) FM + \beta \cdot \Delta I + \Big( \frac{\eta_{FFM}}{\rho_{FFM}} p + \frac{\eta_{FM}}{\rho_{FM}}\cdot (1-p) \Big) \cdot EI + g \cdot \Big(\frac{\eta_{FFM}}{\rho_{FFM}} - \frac{\eta_{FM}}{\rho_{FM}} \Big)}{1 + \frac{\eta_{FFM}}{\rho_{FFM}} p + \frac{\eta_{FM}}{\rho_{FM}}\cdot (1-p) } \end{equation}\] To obtain the initial values for we estimated the initial fat mass using the equations from Deurenberg, Weststrate, and Seidell (1991): \[\begin{equation}\label{fm} FM_{0} = \begin{cases} 1.51 \cdot \text{BMI}_0 - 0.7 \cdot a - \frac{2.2}{100} \cdot BW_0 & \textrm{ if Male}\\\\ 1.51 \cdot BMI_0 - 0.7 \cdot a + \frac{1.4}{100} \cdot BW_0 & \textrm{ if Female} \end{cases} \end{equation}\] where \(a\) represents the age (years); \(\text{BMI}\) the initial body mass index (\(\text{kg}/\text{m}^2\)) and \(BW_0\) the initial body weight of the child. The initial fat free mass is given by the difference between fat mass and body weight: \[\begin{equation}\label{ffm} FFM_0 = BW_0 - FM_0. \end{equation}\]To solve this system of differential equations, we used a 4th order Runge-Kutta algorithm (RK4) Ascher and Greif (2011) with a stepsize \(\Delta t = 1\). RK4 was programmed in C++
for speed and connected to R via the Rcpp
package (Eddelbuettel 2013, Eddelbuettel and François (2011)).
Additional information on the adult’s model, and why to use the dynamic adult model instead of other classical approaches can be found in the package’s vignettes:
browseVignettes("bw")
Ascher, Uri M, and Chen Greif. 2011. A First Course on Numerical Methods. SIAM.
Deurenberg, Paul, Jan A Weststrate, and Jaap C Seidell. 1991. “Body Mass Index as a Measure of Body Fatness: Age-and Sex-Specific Prediction Formulas.” British Journal of Nutrition 65 (2). Cambridge University Press: 105–14.
Eddelbuettel, Dirk. 2013. Seamless R and C++ Integration with Rcpp. New York: Springer.
Eddelbuettel, Dirk, and Romain François. 2011. “Rcpp: Seamless R and C++ Integration.” Journal of Statistical Software 40 (8): 1–18. http://www.jstatsoft.org/v40/i08/.
Ellis, Kenneth J, Roman J Shypailo, Steven A Abrams, and William W Wong. 2000. “The Reference Child and Adolescent Models of Body Composition: A Contemporary Comparison.” Annals of the New York Academy of Sciences 904 (1). Wiley Online Library: 374–82.
Falkner, Frank, and James Mourilyan Tanner. 2012. Human Growth: A Comprehensive Treatise Volume 1 Developmental Biology Prenatal Growth. Springer Science & Business Media.
Fomon, Samuel J, Ferdinand Haschke, Ekhard E Ziegler, and Steven E Nelson. 1982. “Body Composition of Reference Children from Birth to Age 10 Years.” The American Journal of Clinical Nutrition 35 (5). Am Soc Nutrition: 1169–75.
Hall, Kevin D, Nancy F Butte, Boyd A Swinburn, and Carson C Chow. 2013. “Dynamics of Childhood Growth and Obesity: Development and Validation of a Quantitative Mathematical Model.” The Lancet Diabetes & Endocrinology 1 (2). Elsevier: 97–105.
Haschke, F. 1989. “Body Composition During Adolescence.” Body Composition Measurements in Infants and Children. Ross Laboratories Columbus, OH, 76–83.
Katan, Martijn B, Janne C De Ruyter, Lothar DJ Kuijper, Carson C Chow, Kevin D Hall, and Margreet R Olthof. 2016. “Impact of Masked Replacement of Sugar-Sweetened with Sugar-Free Beverages on Body Weight Increases with Initial Bmi: Secondary Analysis of Data from an 18 Month Double–Blind Trial in Children.” PloS One 11 (7). Public Library of Science: e0159771.