-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
131 lines (95 loc) · 3.61 KB
/
README.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
---
title: "bw: Dynamic Body Weight Model"
output: github_document
---
```{r setup, include=FALSE, echo=FALSE, warning=FALSE,message=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(fig.height = 12)
library(ggplot2)
library(bw)
```
The ``bw`` package implements the [Dynamic Weight Change model from _Hall et al._ for adults](https://www.niddk.nih.gov/research-funding/at-niddk/labs-branches/LBM/integrative-physiology-section/research-behind-body-weight-planner/Documents/Hall_Lancet_Web_Appendix.pdf) and the [Children dynamic weight model from Hall **et al**](http://www.thelancet.com/journals/lancet/article/PIIS2213-8587(13)70051-2/abstract) for children.
## Installation
To install the latest version please run the following code:
```{r, eval = FALSE}
if (!require(devtools)){install.packages("devtools")}
devtools::install_github("INSP-RH/bw", build_vignettes = TRUE)
```
## Adult Model
The main function to estimate weight change is ``adult_weight``. It takes as input body weight (kg), height (m),
age (yrs), sex (either `"male"` or `"female"`) either as column vectors from a database or as individual level. In addition it takes a day-by-day `matrix` for change in energy intake from baseline (kcal/day) and another `matrix` for change in sodium (mg/day).
```{r}
#Individual's parameters
bw <- 80
ht <- 1.8
age <- 32
sex <- "female"
#Matrix of energy intake change for 100 days
deltaEI <- rep(-100, 365)
#Function of sodium intake
deltaNA <- rep(-10, 365)
#Estimate weight change.
wtrajectory <- adult_weight(bw, ht, age, sex, deltaEI, deltaNA)
```
The variable `wtrajectory` is a list containing matrices of all the modelled variables:
```{r}
names(wtrajectory)
```
These can be plotted with `model_plot`:
```{r, fig.height=12}
model_plot(wtrajectory)
```
The model can also be used for computing weight change for several individuals at a time:
```{r}
#Antropometric data
weights <- c(45, 67, 58, 92, 81)
heights <- c(1.30, 1.73, 1.77, 1.92, 1.73)
ages <- c(45, 23, 66, 44, 23)
sexes <- c("male", "female", "female", "male", "male")
#Matrix of energy consumption reduction:
EIchange <- rbind(rep(-100, 365), rep(-200, 365), rep(-200, 365),
rep(-123, 365), rep(-50, 365))
#Returns a weight change matrix and other matrices
model_weight <- adult_weight(weights, heights, ages, sexes,
EIchange)
model_plot(model_weight)
```
Average for included variables can be done:
```{r, eval = FALSE}
model_mean(model_weight)
```
```{r, echo = FALSE}
head(model_mean(model_weight))
```
BMI prevalence can be computed:
```{r, eval = FALSE}
adult_bmi(model_weight)
```
```{r, echo = FALSE}
head(adult_bmi(model_weight))
```
## Children Model
The function `child_weight` estimates weight change the same way as `adult_weight`. It takes as input age (yrs), sex ("male" or "female"), fat free mass (kg), and fat mass (kg). The functions `model_mean` and `model_plot` can be also com
A function of energy intake (kcals/yr) for all the years can be inputed.
```{r, fig.height=8}
#Antropometric data
FatFree <- c(32, 17.2, 18.8, 20, 24.1)
Fat <- c(4.30, 2.02, 3.07, 1.12, 2.93)
ages <- c(10, 6.2, 5.4, 4, 4.1)
sexes <- c("male", "female", "female", "male", "male")
#Returns a weight change matrix and other matrices
model_weight <- child_weight(ages, sexes, Fat, FatFree)
#Plot
model_plot(model_weight)
```
Mean by sex:
```{r, eval = FALSE}
model_mean(model_weight, group = sexes)
```
```{r, echo = FALSE}
head(model_mean(model_weight, group = sexes))
```
Additional information on usage can be found on the package's vignette:
```{r, eval = FALSE}
browseVignettes("bw")
```