R Under development (unstable) (2024-09-15 r87152 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(pedbp) > > l <- -0.1600954 > m <- 9.476500305 > s <- 0.11218624 > > stopifnot(isTRUE( + all.equal( + round(qlms(x = 0.05, l = l, m = m, s = s), digits = 2) + , + 7.9 + ) + )) > > # What percentile is the value 8.2? > stopifnot(isTRUE( + all.equal( + round(plms(x = 8.2, l = l, m = m, s = s), digits = 3) + , + 0.096 + ) + )) > > # What is the standard score for the value 8.2 > stopifnot(isTRUE( + all.equal( + zlms(x = 8.2, l = l, m = m, s = s) + , -1.304701 + , tol = 1e-6 + ) + )) > > stopifnot(isTRUE( + all.equal( + zlms(x = 8.2, l = l, m = m, s = s) + , + qnorm(plms(x = 8.2, l = l, m = m, s = s)) + ) + )) > > # for multiple inputs > ps <- seq(0.05, 0.95, by = 0.05) > qs <- qlms(x = ps, l = l, m = m, s = s) > stopifnot(isTRUE(all.equal(plms(qs, l, m, s), ps))) > stopifnot(isTRUE(all.equal(zlms(x = qs, l = l, m = m, s = s), qnorm(ps)))) > > # one quantile or percentile for different LMS values: > d <- pedbp:::lms_data[["bmi_for_age"]][["CDC"]][["Female"]] > stopifnot(isTRUE(all.equal(qlms(x = 0.25, l = d$L, m = d$M, s = d$S), d$P25))) > stopifnot(isTRUE(all.equal(plms(x = d$P25, l = d$L, m = d$M, s = d$S), rep(0.25, nrow(d))))) > > # make sure that the zeros are dealt with > stopifnot(isTRUE( + all.equal( + qlms(x = 0.25, l = 0, m = 4, s = 0.1) + , + exp(0.1 * qnorm(0.25)) * 4 + ) + )) > > stopifnot(isTRUE( + all.equal( + zlms(x = 4.3, l = 0, m = 4, s = 0.1) + , + log(4.3 / 4) / 0.1 + ) + )) > > > ################################################################################ > ## End of File ## > ################################################################################ > > proc.time() user system elapsed 0.26 0.07 0.32