项目作者: INSP-RH

项目描述 :
Dynamic Weight Change Model
高级语言: R
项目地址: git://github.com/INSP-RH/bw.git
创建时间: 2017-06-16T20:31:30Z
项目社区:https://github.com/INSP-RH/bw

开源协议:Other

下载


bw: Dynamic Body Weight Model

The bw package implements the Dynamic Weight Change model from Hall et al. for adults and the Children dynamic weight model from Hall et al70051-2/abstract) for children.

Installation

To install the latest version please run the following code:

  1. if (!require(devtools)){install.packages("devtools")}
  2. devtools::install_github("INSP-RH/bw")

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).

  1. #Individual's parameters
  2. bw <- 80
  3. ht <- 1.8
  4. age <- 32
  5. sex <- "female"
  6. #Matrix of energy intake change for 100 days
  7. deltaEI <- rep(-100, 365)
  8. #Function of sodium intake
  9. deltaNA <- rep(-10, 365)
  10. #Estimate weight change.
  11. wtrajectory <- adult_weight(bw, ht, age, sex, deltaEI, deltaNA)

The variable wtrajectory is a list containing matrices of all the modelled variables:

  1. names(wtrajectory)
  1. ## [1] "Time" "Age"
  2. ## [3] "Adaptive_Thermogenesis" "Extracellular_Fluid"
  3. ## [5] "Glycogen" "Fat_Mass"
  4. ## [7] "Lean_Mass" "Body_Weight"
  5. ## [9] "Body_Mass_Index" "BMI_Category"
  6. ## [11] "Energy_Intake" "Correct_Values"

These can be plotted with model_plot:

  1. model_plot(wtrajectory)

The model can also be used for computing weight change for several individuals at a time:

  1. #Antropometric data
  2. weights <- c(45, 67, 58, 92, 81)
  3. heights <- c(1.30, 1.73, 1.77, 1.92, 1.73)
  4. ages <- c(45, 23, 66, 44, 23)
  5. sexes <- c("male", "female", "female", "male", "male")
  6. #Matrix of energy consumption reduction:
  7. EIchange <- rbind(rep(-100, 365), rep(-200, 365), rep(-200, 365),
  8. rep(-123, 365), rep(-50, 365))
  9. #Returns a weight change matrix and other matrices
  10. model_weight <- adult_weight(weights, heights, ages, sexes,
  11. EIchange)
  12. model_plot(model_weight)

Average for included variables can be done:

  1. model_mean(model_weight)
  1. ## time variable group mean SE_mean Lower_CI_mean
  2. ## 1 1 Age 1 40.20000 8.046117 24.42990
  3. ## 2 1 Adaptive_Thermogenesis 1 0.00000 0.000000 0.00000
  4. ## 3 1 Extracellular_Fluid 1 17.68290 2.445504 12.88980
  5. ## 4 1 Glycogen 1 0.50000 0.000000 0.50000
  6. ## 5 1 Fat_Mass 1 16.11919 1.634683 12.91527
  7. ## 6 1 Lean_Mass 1 32.94791 4.340489 24.44071
  8. ## Upper_CI_mean variance SE_variance Lower_CI_variance Upper_CI_variance
  9. ## 1 55.97010 323.70000 148.838516 31.981870 615.41813
  10. ## 2 0.00000 0.00000 0.000000 0.000000 0.00000
  11. ## 3 22.47600 29.90246 16.471194 -2.380486 62.18541
  12. ## 4 0.50000 0.00000 0.000000 0.000000 0.00000
  13. ## 5 19.32311 13.36094 5.819498 1.954934 24.76695
  14. ## 6 41.45512 94.19923 31.078690 33.286112 155.11234

BMI prevalence can be computed:

  1. adult_bmi(model_weight)
  1. ## Day Group BMI_Category Mean 2.5 % 97.5 %
  2. ## 1 1 1 Normal 0.6 0.11990883 1.0800912
  3. ## 2 1 1 Pre-Obese 0.4 -0.08009117 0.8800912
  4. ## 3 2 1 Mild Thinness 0.2 -0.19199280 0.5919928
  5. ## 4 2 1 Normal 0.4 -0.08009117 0.8800912
  6. ## 5 2 1 Pre-Obese 0.4 -0.08009117 0.8800912
  7. ## 6 2 1 Mild Thinness 0.2 -0.19199280 0.5919928

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.

  1. #Antropometric data
  2. FatFree <- c(32, 17.2, 18.8, 20, 24.1)
  3. Fat <- c(4.30, 2.02, 3.07, 1.12, 2.93)
  4. ages <- c(10, 6.2, 5.4, 4, 4.1)
  5. sexes <- c("male", "female", "female", "male", "male")
  6. #Returns a weight change matrix and other matrices
  7. model_weight <- child_weight(ages, sexes, Fat, FatFree)
  8. #Plot
  9. model_plot(model_weight)

Mean by sex:

  1. model_mean(model_weight, group = sexes)
  1. ## time variable group mean SE_mean Lower_CI_mean
  2. ## 1 1 Age female 5.800000 0.3162278 5.180205
  3. ## 2 1 Age male 6.033333 1.8107191 2.484389
  4. ## 3 1 Fat_Free_Mass female 2.545000 0.4150489 1.731519
  5. ## 4 1 Fat_Free_Mass male 2.783333 0.8406732 1.135644
  6. ## 5 1 Fat_Mass female 18.000000 0.6324555 16.760410
  7. ## 6 1 Fat_Mass male 25.366667 3.2146943 19.065982
  8. ## Upper_CI_mean variance SE_variance Lower_CI_variance Upper_CI_variance
  9. ## 1 6.419795 0.320000 5.488310e-16 0.3200000 0.320000
  10. ## 2 9.582278 11.803333 5.387460e+00 1.2441059 22.362561
  11. ## 3 3.358481 0.551250 0.000000e+00 0.5512500 0.551250
  12. ## 4 4.431023 2.544233 1.161278e+00 0.2681696 4.820297
  13. ## 5 19.239590 1.280000 0.000000e+00 1.2800000 1.280000
  14. ## 6 31.667352 37.203333 1.698092e+01 3.9213403 70.485326

Additional information on usage can be found on the package’s vignette:

  1. browseVignettes("bw")