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.671626760 3.3439972
#> 2 1.5 f -1.791215353 3.2956887
#> 3 2.5 m -0.035406213 0.5389870
#> 4 3.5 m -1.372232915 0.7982117
#> 5 4.5 f -0.087246258 0.4424324
#> 6 5.5 f 1.412973388 2.5899800
#> 7 6.5 m 0.005551381 3.8367270
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.671626760 3.3439972 1.0025987
#> 2 1.5 f -1.791215353 3.2956887 1.7089478
#> 3 2.5 m -0.035406213 0.5389870 -0.6052416
#> 4 3.5 m -1.372232915 0.7982117 0.3396781
#> 5 4.5 f -0.087246258 0.4424324 -1.5218721
#> 6 5.5 f 1.412973388 2.5899800 -0.7537761
#> 7 6.5 m 0.005551381 3.8367270 1.5759191For 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 f -0.03175854 1.1766335
#> 2 1.5 f 0.33625781 4.8481103
#> 3 2.5 m 0.22763299 1.6669762
#> 4 3.5 m -0.17610244 0.9044051
#> 5 4.5 f 0.31691588 1.8328071
#> 6 5.5 f -0.06123598 2.8132838
#> 7 6.5 m 1.12656866 0.4990086df$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 f -0.03175854 1.1766335 -1.23390655
#> 2 1.5 f 0.33625781 4.8481103 1.71363993
#> 3 2.5 m 0.22763299 1.6669762 1.02375428
#> 4 3.5 m -0.17610244 0.9044051 0.17244964
#> 5 4.5 f 0.31691588 1.8328071 -0.09520083
#> 6 5.5 f -0.06123598 2.8132838 0.93208840
#> 7 6.5 m 1.12656866 0.4990086 -1.45839493df$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 f -0.03175854 1.1766335 -1.23390655 10.86
#> 2 1.5 f 0.33625781 4.8481103 1.71363993 95.67
#> 3 2.5 m 0.22763299 1.6669762 1.02375428 84.70
#> 4 3.5 m -0.17610244 0.9044051 0.17244964 56.85
#> 5 4.5 f 0.31691588 1.8328071 -0.09520083 46.21
#> 6 5.5 f -0.06123598 2.8132838 0.93208840 82.44
#> 7 6.5 m 1.12656866 0.4990086 -1.45839493 7.24For 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 20.22672 11.415466
#> 2 30 M 22.58503 11.929952
#> 3 40 M 39.09304 14.820182
#> 4 50 M 37.00556 17.562817
#> 5 60 M 20.91538 17.427235
#> 6 70 F 33.93780 2.031890
#> 7 80 F 35.09153 6.806497
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 20.22672 11.415466 1.7301199
#> 2 30 M 22.58503 11.929952 1.7550914
#> 3 40 M 39.09304 14.820182 -0.6199196
#> 4 50 M 37.00556 17.562817 0.3818902
#> 5 60 M 20.91538 17.427235 1.9878247
#> 6 70 F 33.93780 2.031890 -2.1758310
#> 7 80 F 35.09153 6.806497 -1.7912624