library(childsds)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
data(leptin.ref)For children and adolescents up to an age of 18.5 years, leptin
standard deviation scores will be calclated based on age on years and
BMI-SDS. BMI-SDS via the x2= argument to the
sds_2d() function.
Besides, the sds_2d() function takes the leptin value
(value=), sex (sex=) and age
(age=) as arguments. These values have to be given as
vectors of the same length. In addition, it needs a reference object (in
our case ref=leptin.ref) and the item (item=).
For children younger than 6, the item is ‘leptin_until6’, for children
between 6 and 18, it is ‘leptin_6to18’. The function returns a numeric
vector of the same length containing leptin-SDS
(type="SDS") or leptin percentiles
(type="perc").
df <- data.frame(age = seq(0.5, 6.5, by = 1),
sex = sample(c("m","f"),7, replace = T),
bmisds = rnorm(7),
leptin = runif(7, min = 0.01, max = 5))
df
#> age sex bmisds leptin
#> 1 0.5 m -0.8305965 0.9582547
#> 2 1.5 f -1.7128831 4.9439767
#> 3 2.5 m -1.0591692 2.1781553
#> 4 3.5 f 1.6580318 4.1427139
#> 5 4.5 m -2.5772128 3.5125280
#> 6 5.5 f 0.4939467 1.9042443
#> 7 6.5 m -0.8573069 2.6832178
df$leptin_sds <- sds_2d(value = df$leptin,
age = df$age,
x2 = df$bmisds,
sex = df$sex, male = "m", female = "f",
item = "leptin_until6",
ref = leptin.ref)
df
#> age sex bmisds leptin leptin_sds
#> 1 0.5 m -0.8305965 0.9582547 -1.00768721
#> 2 1.5 f -1.7128831 4.9439767 1.95731273
#> 3 2.5 m -1.0591692 2.1781553 1.66700394
#> 4 3.5 f 1.6580318 4.1427139 -0.03956513
#> 5 4.5 m -2.5772128 3.5125280 2.10226469
#> 6 5.5 f 0.4939467 1.9042443 -0.30655716
#> 7 6.5 m -0.8573069 2.6832178 1.70409086For SDS adjusted for pubertal stage, you have to use the function
sds_pub2d(). Again, the leptin value (value=),
the Tanner stage (1-5, pubstat=), the BMI-SDS
(x2=) and the sex (sex=) has to be given to
the function as vectors of the same length. The ref object
is still leptin.ref and the item=lep_pub. The
reference values are valid for the age range 6-18.
sds_pub2d(value = 20,
pubstat = 2,
x2 = 1,
sex = "male",
item = "lep_pub", ref = leptin.ref)
#> [1] 1.946403df <- data.frame(age = seq(0.5, 6.5, by = 1),
sex = sample(c("m","f"),7, replace = T),
bmisds = rnorm(7),
leptin = runif(7, min = 0.01, max = 5))
df
#> age sex bmisds leptin
#> 1 0.5 m 1.84849669 2.0385530
#> 2 1.5 m -2.02076167 1.7131592
#> 3 2.5 m -0.08081032 1.7625253
#> 4 3.5 m -0.49209189 3.0676671
#> 5 4.5 f 0.89546293 4.6620092
#> 6 5.5 f -0.06942089 0.1878081
#> 7 6.5 m 1.86000661 1.2655091df$leptin_sds <- sds_2d(value = df$leptin,
age = df$age,
x2 = df$bmisds,
sex = df$sex, male = "m", female = "f",
item = "leptin_until6",
ref = leptin.ref)
df
#> age sex bmisds leptin leptin_sds
#> 1 0.5 m 1.84849669 2.0385530 -0.8903689
#> 2 1.5 m -2.02076167 1.7131592 0.8589348
#> 3 2.5 m -0.08081032 1.7625253 1.2280372
#> 4 3.5 m -0.49209189 3.0676671 1.7891847
#> 5 4.5 f 0.89546293 4.6620092 1.0648736
#> 6 5.5 f -0.06942089 0.1878081 -1.9118419
#> 7 6.5 m 1.86000661 1.2655091 -1.3163763df$leptin_perc <- sds_2d(value = df$leptin,
age = df$age,
x2 = df$bmisds,
sex = df$sex, male = "m", female = "f",
item = "leptin_until6",
type = "perc",
ref = leptin.ref)
df
#> age sex bmisds leptin leptin_sds leptin_perc
#> 1 0.5 m 1.84849669 2.0385530 -0.8903689 18.66
#> 2 1.5 m -2.02076167 1.7131592 0.8589348 80.48
#> 3 2.5 m -0.08081032 1.7625253 1.2280372 89.03
#> 4 3.5 m -0.49209189 3.0676671 1.7891847 96.32
#> 5 4.5 f 0.89546293 4.6620092 1.0648736 85.65
#> 6 5.5 f -0.06942089 0.1878081 -1.9118419 2.79
#> 7 6.5 m 1.86000661 1.2655091 -1.3163763 9.40For adults until 80 years, leptin standard deviation scores will be
calclated based on age on years and BMI. BMI is passed to the
sds_2d() function via the x2= argument.
Besides, the sds_2d() function takes the leptin value
(value=), sex (sex=) and age
(age=) as arguments. These values have to be given as
vectors of the same length. In addition, it needs a reference object (in
our case ref=leptin.ref) and the item (item=).
For adults, it is ‘lep_bmi’. The function returns a numeric vector of
the same length containing leptin-SDS (type="SDS") or
leptin percentiles (type="perc").
df <- data.frame(age = seq(20, 80, by = 10),
sex = sample(c("M","F"),7, replace = T),
bmi = runif(7, 20, 40),
leptin = runif(7, min = 0.01, max = 20))
df
#> age sex bmi leptin
#> 1 20 M 21.60329 1.872813
#> 2 30 M 22.35902 18.568764
#> 3 40 F 33.11992 13.293978
#> 4 50 M 39.96334 10.679212
#> 5 60 F 29.10451 15.622017
#> 6 70 F 28.57481 3.640949
#> 7 80 M 29.75416 4.242302
df$leptin_sds <- sds_2d(value = df$leptin,
age = df$age,
x2 = df$bmi,
sex = df$sex, male = "M", female = "F",
item = "lep_bmi",
ref = leptin.ref)
df
#> age sex bmi leptin leptin_sds
#> 1 20 M 21.60329 1.872813 0.5162884
#> 2 30 M 22.35902 18.568764 1.9300235
#> 3 40 F 33.11992 13.293978 -1.2396054
#> 4 50 M 39.96334 10.679212 -1.0350738
#> 5 60 F 29.10451 15.622017 -0.5433393
#> 6 70 F 28.57481 3.640949 -1.8091181
#> 7 80 M 29.75416 4.242302 -1.1297879