Description Usage Arguments Details Author(s) Examples
Gets survey proportions svytable
, standard error and
confidence interval estimates of BMI from adult_weight
.
1 2 3 4 5 |
weight |
(list) List from Optional |
days |
(vector) Vector of days in which to compute the estimates |
group |
(vector) Variable in which to group the results. |
design |
A |
confidence |
(numeric) Confidence level ( |
The default design
is that of simple random sampling.
Dalia Camacho-García-Formentí daliaf172@gmail.com
Rodrigo Zepeda-Tello rzepeda17@gmail.com
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.