adult_bmi: Get BMI prevalence results from Adult Weight Change Model

Description Usage Arguments Details Author(s) Examples

View source: R/adult_bmi.R

Description

Gets survey proportions svytable, standard error and confidence interval estimates of BMI from adult_weight.

Usage

1
2
3
4
5
adult_bmi(weight, days = seq(0, length(weight[["Time"]]) - 1, length.out =
  25), group = rep(1, nrow(weight[["BMI_Category"]])),
  design = svydesign(ids = ~1, weights = rep(1,
  nrow(weight[["BMI_Category"]])), data =
  as.data.frame(weight[["BMI_Category"]])), confidence = 0.95)

Arguments

weight

(list) List from adult_weight

Optional

days

(vector) Vector of days in which to compute the estimates

group

(vector) Variable in which to group the results.

design

A survey.design object. See svydesign for additional information on design objects.

confidence

(numeric) Confidence level (default = 0.95)

Details

The default design is that of simple random sampling.

Author(s)

Dalia Camacho-García-Formentí daliaf172@gmail.com

Rodrigo Zepeda-Tello rzepeda17@gmail.com

Examples

 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
#EXAMPLE 1: RANDOM SAMPLE MODELLING
#--------------------------------------------------------

#Antropometric data
weights <- c(45, 67, 58, 67, 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))

#Create weight change model
model_weight <- adult_weight(weights, heights, ages, sexes, 
                             EIchange)
                             
#Calculate proportions
adult_bmi(model_weight)

#EXAMPLE 2: Survey data
#-------------------------------------------------------
set.seed(7423)

#Data frame for use in survey
probs   <- runif(10, 20, 60)
datasvy <- data.frame(
  id    = 1:10,
  bw    = runif(10,60,90),
  ht    = runif(10, 1.5, 2),
  age   = runif(10, 18, 80),
  sex   = sample(c("male","female"),10, replace = TRUE),
  kcal  = runif(10, 2000, 3000),
  group = sample(c(0,1), 10, replace = TRUE),
  svyw  = probs/sum(probs))

#Days to model
days <- 365

#Energy intake matrix
EIchange <- matrix(NA, ncol = days, nrow = 0)
for(i in 1:nrow(datasvy)){
    EIchange <- rbind(EIchange, rep(datasvy$kcal[i], days))
}

#Calculate weight change                   
weight <- adult_weight(datasvy$bw, datasvy$ht, datasvy$age, 
                          datasvy$sex, EIchange)


#Create survey design using survey package                           
design <- survey::svydesign(id = ~id, weights = datasvy$svyw, 
data = datasvy)
   
#' #Group to calculate means
group  <- datasvy$group     

#Calculate survey mean and variance for 25 days
adult_bmi(weight, design = design, group = group)
 

bw documentation built on July 5, 2018, 5:03 p.m.