Title: | Analysis of Growth Data |
---|---|
Description: | Tools for the analysis of growth data: to extract an LMS table from a gamlss object, to calculate the standard deviation scores and its inverse, and to superpose two wormplots from different models. The package contains a some varieties of reference tables, especially for The Netherlands. |
Authors: | Stef van Buuren [aut, cre] |
Maintainer: | Stef van Buuren <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 0.45.0 |
Built: | 2025-02-16 02:44:42 UTC |
Source: | https://github.com/stefvanbuuren/agd |
Creates an age grid according to a specified format.
ageGrid(grid = "compact")
ageGrid(grid = "compact")
grid |
A character string specifying one of the following:
|
A list with five components: format
, year
,
month
, week
and day
containing the age grid in different
units.
Stef van Buuren, 2010
age <- ageGrid("classic")$year
age <- ageGrid("classic")$year
Height, weight, head circumference and puberty of 7482 Dutch boys.
A data frame with 7482 rows on the following 9 variables:
Decimal age (0-21 years)
Height (cm)
Weight (kg)
Body mass index
Head circumference (cm)
Genital Tanner stage (G1-G5)
Pubic hair (Tanner P1-P6)
Testicular volume (ml)
Region (north, east, west, south, city)
The complete sample of cross-sectional data from boys 0-21 years used to
construct the Dutch growth references 1997. Variables gen
and
phb
are ordered factors. reg
is a factor. Note: A 10% sample
from this data is available in data set boys
in the mice
package.
Stef van Buuren, 2012
Fredriks, A.M,, van Buuren, S., Burgmeijer, R.J., Meulmeester JF, Beuker, R.J., Brugman, E., Roede, M.J., Verloove-Vanhorick, S.P., Wit, J.M. (2000) Continuing positive secular growth change in The Netherlands 1955-1997. Pediatric Research, 47, 316-323.
Fredriks, A.M., van Buuren, S., Wit, J.M., Verloove-Vanhorick, S.P. (2000). Body index measurements in 1996-7 compared with 1980. Archives of Disease in Childhood, 82, 107-112.
Extract LMS values from a gamlss object for solutions that transform the age axis according to the M-curve.
extractLMS( fit, data, sex = "M", grid = "classic", decimals = c(4, 4, 4), flatAge = NULL )
extractLMS( fit, data, sex = "M", grid = "classic", decimals = c(4, 4, 4), flatAge = NULL )
fit |
A gamlss object containing the final fit on transformed age,
|
data |
A data frame containing the original data, with both |
sex |
A character vector indicating whether the fit applied to males
|
grid |
A character vector indicating the desired age grid. See
|
decimals |
A numerical vector of length 3 indicating the number of significant digits for rounding of the L, M and S curves, respectively. |
flatAge |
A scalar indicating the age beyond which the L, M and S values should be constant. The default (NULL) is not to flatten the curves. |
It is crucial that t.age
in data
correspond to exactly the same
age transformation as used to fit the gamlss
object. Age grid values
beyond the range of data$age
produce NA
in the L, M and S
values. Parameter flatAge
should be one of the values of the age grid.
A data frame with rows corresponding to time points, and with the
following columns: sex
,x
,L
,M
,S
.
Stef van Buuren, 2010
## Not run: # library(gamlss) boys <- boys7482 # calculate initial M curve data <- na.omit(boys[,1:2]) f0154 <- gamlss(hgt~cs(age,df=15,c.spar=c(-1.5,2.5)), sigma.formula=~cs(age,df=4,c.spar=c(-1.5,2.5)), data=data,family=NO, control=gamlss.control(n.cyc=3)) # calculate transformed age t.age <- fitted(lm(data$age~fitted(f0154))) t.age <- t.age - min(t.age) data.t <- data.frame(data,t.age=t.age) # calculate final solution f0106r <- gamlss(hgt~cs(t.age,df=10,c.spar=c(-1.5,2.5)), sigma.formula=~cs(t.age,df=6,c.spar=c(-1.5,2.5)), data=data.t,family=NO, control=gamlss.control(n.cyc=3)) # extract the LMS reference table in the 'classic' age grid nl4.hgt.boys <- extractLMS(fit = f0106r, data=data.t, grid="compact", dec = c(0,2,5)) nl4.hgt.boys # flatten the reference beyond age 20Y (not very useful in this data) nl4.hgt.boys.flat <- extractLMS(fit = f0106r, data=data.t, flatAge=20) nl4.hgt.boys.flat # use log age transformation data.t <- data.frame(data, t.age = log(data$age)) f0106rlog <- gamlss(hgt~cs(t.age,df=10,c.spar=c(-1.5,2.5)), sigma.formula=~cs(t.age,df=6,c.spar=c(-1.5,2.5)), data=data.t,family=NO, control=gamlss.control(n.cyc=1)) nl4.hgt.boys.log <- extractLMS(fit = f0106rlog, data=data.t) nl4.hgt.boys.log ## End(Not run)
## Not run: # library(gamlss) boys <- boys7482 # calculate initial M curve data <- na.omit(boys[,1:2]) f0154 <- gamlss(hgt~cs(age,df=15,c.spar=c(-1.5,2.5)), sigma.formula=~cs(age,df=4,c.spar=c(-1.5,2.5)), data=data,family=NO, control=gamlss.control(n.cyc=3)) # calculate transformed age t.age <- fitted(lm(data$age~fitted(f0154))) t.age <- t.age - min(t.age) data.t <- data.frame(data,t.age=t.age) # calculate final solution f0106r <- gamlss(hgt~cs(t.age,df=10,c.spar=c(-1.5,2.5)), sigma.formula=~cs(t.age,df=6,c.spar=c(-1.5,2.5)), data=data.t,family=NO, control=gamlss.control(n.cyc=3)) # extract the LMS reference table in the 'classic' age grid nl4.hgt.boys <- extractLMS(fit = f0106r, data=data.t, grid="compact", dec = c(0,2,5)) nl4.hgt.boys # flatten the reference beyond age 20Y (not very useful in this data) nl4.hgt.boys.flat <- extractLMS(fit = f0106r, data=data.t, flatAge=20) nl4.hgt.boys.flat # use log age transformation data.t <- data.frame(data, t.age = log(data$age)) f0106rlog <- gamlss(hgt~cs(t.age,df=10,c.spar=c(-1.5,2.5)), sigma.formula=~cs(t.age,df=6,c.spar=c(-1.5,2.5)), data=data.t,family=NO, control=gamlss.control(n.cyc=1)) nl4.hgt.boys.log <- extractLMS(fit = f0106rlog, data=data.t) nl4.hgt.boys.log ## End(Not run)
Reference tables from CDC 2000
A data frame with seven variables:
Study Population
Subpopulation
Sex (M,F)
Decimal age (0-5 years)
Lambda (skewness) curve
Median curve
Coefficient of Variation curve
The models were fitted by the LMS model. Parameters are stored as type
LMS
. Tabulated values are point ages.
The naming conventions are as follows:
Combined length/height (cm) for Age, 0-20 years. Measures <2 years apply to length (lying), while ages >= 2 years apply to height, or stature (standing).
Weight (kg) for Age, 0-20 years.
Body Mass Index (kg/m2) for Age, 2-20 years.
Kuczmarski RJ, Ogden CL, Guo SS, Grummer-Strawn LM, Flegal KM, Mei Z, Wei R, Curtin LR, Roche AF, Johnson CL. 2000 CDC growth charts for the United States: methods and development. Vital Health Stat, 2002, 11, 246, 1-190.
nl4.wgt
, nl4.hgt
, nl4.bmi
,
who.wgt
Reference table from the Third Dutch Growth Study 1980
A data frame with seven variables:
Study Population
Subpopulation, e.g.
ethnicity or age group (for nl4.wfh
)
Sex (M,F)
Decimal age (0-21 years) or Height (for nl4.wfh
)
Lambda (skewness) curve
Median curve
Coefficient of Variation curve
The model was fitted by the LMS model. Parameters are stored as type
LMS
. Tabulated values are point ages.
Height follows a normal distribution, with all lambda parameters set equal to
1. The standard deviation (in cm) is obtained as S*M
.
The naming conventions are as follows:
Length/Height (cm) for Age
Weight (kg) for Age
Weight (kg) for Height (cm)
Head circumference (cm) for Age
Leg Length (cm) for Age
Hip circumference (cm) for Age
Waist circumference (cm) for Age
Waist/Hip ratio for Age
Sitting Height for Age
Sitting Height/Height ratio for Age
Fredriks, A.M,, van Buuren, S., Burgmeijer, R.J., Meulmeester JF, Beuker, R.J., Brugman, E., Roede, M.J., Verloove-Vanhorick, S.P., Wit, J.M. (2000) Continuing positive secular growth change in The Netherlands 1955-1997. Pediatric Research, 47, 316-323.
Fredriks, A.M., van Buuren, S., Wit, J.M., Verloove-Vanhorick, S.P. (2000). Body index measurements in 1996-7 compared with 1980. Archives of Disease in Childhood, 82, 107-112.
Reference table from the Fourth Dutch Growth Study 1997
A data frame with seven variables:
Study Population
Subpopulation, e.g.
ethnicity or age group (for nl4.wfh
)
Sex (M,F)
Decimal age (0-21 years) or Height (for nl4.wfh
)
Lambda (skewness) curve
Median curve
Coefficient of Variation curve
The model was fitted by the LMS model. Parameters are stored as type
LMS
. Tabulated values are point ages.
Height follows a normal distribution, with all lambda parameters set equal to
1. The standard deviation (in cm) is obtained as S*M
.
The naming conventions are as follows:
Length/Height (cm) for Age
Weight (kg) for Age
Weight (kg) for Height (cm)
Head circumference (cm) for Age
Leg Length (cm) for Age
Hip circumference (cm) for Age
Waist circumference (cm) for Age
Waist/Hip ratio for Age
Sitting Height for Age
Sitting Height/Height ratio for Age
Fredriks, A.M,, van Buuren, S., Burgmeijer, R.J., Meulmeester JF, Beuker, R.J., Brugman, E., Roede, M.J., Verloove-Vanhorick, S.P., Wit, J.M. (2000) Continuing positive secular growth change in The Netherlands 1955-1997. Pediatric Research, 47, 316-323.
Fredriks, A.M., van Buuren, S., Wit, J.M., Verloove-Vanhorick, S.P. (2000). Body index measurements in 1996-7 compared with 1980. Archives of Disease in Childhood, 82, 107-112.
Reference tables, combined from the WHO Multicentre Growth Reference Study (MGRS) (ages 0-5 years) and the WHO 2007 reference (5-19 years).
A data frame with seven variables:
Study Population (always "who"
)
Subpopulation (always "N"
)
Sex (M, F)
Decimal age, height (cm) or length(cm)
Lambda (skewness) curve
Median curve
Coefficient of variation
The data were fitted by the LMS model. Parameters are stored as type
LMS
. Tabulated values are point ages.
The naming conventions are as follows:
Length (cm, 0-2 Yrs) or height (cm, 2-19 years)
Weight (kg) for age (0-10 years)
BMI (kg/m^2) for age (0-19 years)
Head circumference (cm) for age (0-5 years)
Weight (kg) for height (65-120 cm)
Weight (kg) for length (45-110 cm)
WHO Multicentre Growth Reference Study Group. WHO Child Growth Standards based on length/height, weight and age. Acta Paediatr, Suppl. 2006, 450, 76-85.
de Onis M, Onyango AW, Borghi E, Siyam A, Nishida C, Siekmann J. Development of a WHO growth reference for school-aged children and adolescents Bulletin of the World Health Organization, 2007;85:660-7.
Superposes two worm plots from GAMLSS fitted objects. This is a diagnostic tool for comparing two solutions.
wp.twin( obj1, obj2 = NULL, xvar = NULL, xvar.column = 2, n.inter = 16, show.given = FALSE, ylim.worm = 0.5, line = FALSE, cex = 1, col1 = "black", col2 = "orange", warnings = FALSE, ... )
wp.twin( obj1, obj2 = NULL, xvar = NULL, xvar.column = 2, n.inter = 16, show.given = FALSE, ylim.worm = 0.5, line = FALSE, cex = 1, col1 = "black", col2 = "orange", warnings = FALSE, ... )
obj1 |
a GAMLSS fitted object |
obj2 |
an optional second GAMLSS fitted object |
xvar |
the explanatory variable against which the worm plots will be plotted |
xvar.column |
the number referring to the column of |
n.inter |
the number of intervals in which the explanatory variable
|
show.given |
whether to show the x-variable intervals in the top of the
graph, default is |
ylim.worm |
for multiple plots, this values is the y-variable limit,
default value is |
line |
whether to plot the polynomial line in the worm plot, default
value is |
cex |
the cex plotting parameter with default |
col1 |
the color for the points of |
col2 |
the color for the points of |
warnings |
a logical indicating whether warnings should be produced. The
default |
... |
for extra arguments, |
This function is a customized version of the wp()
function found in
the gamlss
package. Function wp.twin()
allows overplotting of
two worm plots, each in its own color. The points of obj1
are plotted
first, the points of obj2
are superposed. This twin worm plot provide
a visual assessment of the differences between the solutions. Extra
arguments can be specified (e.g. xvar
) that are passed down to the
wp()
function of gamlss
if specified. The worm plot is a
detrended normal QQ-plot that highlight departures from normality.
Argument xvar
takes priority over xvar.column
. The xvar
variable is cut into n.iter
intervals with an equal number
observations and detrended normal QQ (i.e. worm) plots for each interval are
plotted. This is a way of highlighting failures of the model within
different ranges of the explanatory variable.
If line=TRUE
and n.inter>1
, the fitted coefficients from
fitting cubic polynomials to the residuals (within each x-variable interval)
can be obtain by e.g. coeffs<-wp.twin(model1,xvar=x,n.iner=9)
. van
Buuren et al. (2001) used these residuals to identify regions
(intervals) of the explanatory variable within which the model does not fit
adequately the data (called "model violation")
For multiple plots the xvar
intervals and the coefficients of
the fitted cubic polynomials to the residuals (within each xvar
interval) are returned.
Stef van Buuren, using R code of Mikis Stasinopoulos and Bob Rigby
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R. Journal of Statistical Software, Vol. 23, Issue 7, Dec 2007, https://www.jstatsoft.org/v23/i07.
van Buuren and Fredriks M. (2001) Worm plot: simple diagnostic device for modelling growth reference curves. Statistics in Medicine, 20, 1259–1277.
van Buuren and Fredriks M. (2007) Worm plot to diagnose fit in quantile regression. Statistical Modelling, 7, 4, 363–376.
## Not run: library(gamlss) data(abdom) a <- gamlss(y~cs(x,df=1),sigma.fo=~cs(x,0),family=LO,data=abdom) b <- gamlss(y~cs(x,df=3),sigma.fo=~cs(x,1),family=LO,data=abdom) coeff1 <- wp.twin(a,b,line=TRUE) ## End(Not run)
## Not run: library(gamlss) data(abdom) a <- gamlss(y~cs(x,df=1),sigma.fo=~cs(x,0),family=LO,data=abdom) b <- gamlss(y~cs(x,df=3),sigma.fo=~cs(x,1),family=LO,data=abdom) coeff1 <- wp.twin(a,b,line=TRUE) ## End(Not run)
Converts measurements into age- and sex-conditional standard deviation score (SDS) using an external reference.
y2z( y = c(75, 80, 85), x = 1, sex = "M", sub = "N", ref = get("nl4.hgt"), dist = "LMS", dec = 3, sex.fallback = NA, sub.fallback = NA, tail.adjust = FALSE )
y2z( y = c(75, 80, 85), x = 1, sex = "M", sub = "N", ref = get("nl4.hgt"), dist = "LMS", dec = 3, sex.fallback = NA, sub.fallback = NA, tail.adjust = FALSE )
y |
A numerical vector containing the outcome measurements. The length
|
x |
A vector containing the values of the numerical covariate (typically
decimal age or height) at which conversion is desired. Values are replicated
to match |
sex |
A character vector indicating whether the male ( |
sub |
A character vector indicating the level of the |
ref |
A data frame containing a factor |
dist |
A string identifying the type of distribution. Values values are:
|
dec |
A scalar value indicating the number of decimals used to round the value. |
sex.fallback |
The level of the |
sub.fallback |
The level of the |
tail.adjust |
Logical. If |
Functions z2y()
and y2z()
are the inverse of each other.
The argument dist
determines the statistical distribution. The
possibilities are as follows:
ref
should contain columns mean
and sd
, containing the mean and the
standard deviation in the external reference population.
ref
should contain columns L
, S
and M
containing the LMS parameters.
ref
should contain columns mu
,
sigma
and nu
containing the Box-Cox Cole-Green parameters.
ref
should contain columns mu
,
sigma
, nu
and tau
containing the Box-Cox Power
Exponential parameters.
ref
should contain
columns mu
, sigma
, nu
and tau
containing the
Box-Cox T distribution parameters.
For y2z()
: A vector with length(y)
elements containing
the standard deviation score. For z2y()
: A vector with
length(z)
elements containing quantiles.
Stef van Buuren, 2010
boys <- boys7482 # SDS of height 115 cm at age 5 years, # relative to Dutch boys reference y2z(y=115, x=5) # same relative to Dutch girls y2z(y=115, x=5, sex="F") # SDS of IOTF BMI cut-off value for overweight (boys 2-18) # relative to Dutch boys reference cutoff <- c( 18.41, 18.15, 17.89, 17.72, 17.55, 17.49, 17.42, 17.49, 17.55, 17.74, 17.92, 18.18, 18.44, 18.77, 19.10, 19.47, 19.84, 20.20, 20.55, 20.89, 21.22, 21.57, 21.91, 22.27, 22.62, 22.96, 23.29, 23.60, 23.90, 24.18, 24.46, 24.73, 25.00) age <- seq(2, 18, by=0.5) (z <- y2z(y=cutoff, x=age, sex="M", ref=nl4.bmi)) # apply inverse transformation to check calculations round(z2y(z, age, ref=nl4.bmi), 2) cutoff # calculate percentiles of weight 12 kg at 2 years (boys, girls) 100*round(pnorm(y2z(y=c(12,12), x=2, sex=c("M","F"), ref=nl4.wgt)),2) # # percentage of children lighter than 15kg at ages 2-5 e <- expand.grid(age=2:5, sex=c("M","F")) z <- y2z(y=rep(15,nrow(e)), x=e$age, sex=e$sex, ref=nl4.wgt) w <- matrix(100*round(pnorm(z),2), nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),2:5) w # analysis in Z scale hgt.z <- y2z(y=boys$hgt, x=boys$age, sex="M", ref=nl4.hgt) wgt.z <- y2z(y=boys$wgt, x=boys$age, sex="M", ref=nl4.wgt) plot(hgt.z, wgt.z, col="blue") # z2y # quantile at SD=0 of age 2 years, # height Dutch boys z2y(z=0, x=2) # same for Dutch girls z2y(z=0, x=2, sex="F") # quantile at SD=c(-1,0,1) of age 2 years, BMI Dutch boys z2y(z=c(-1,0,+1), x=2, ref=nl4.bmi) # 0SD line (P50) in kg of weight for age in 5-10 year, Dutch boys z2y(z=rep(0,6), x=5:10, ref=nl4.wgt) # 95th percentile (P95), age 10 years, wfa, Dutch boys z2y(z=qnorm(0.95), x=10, ref=nl4.wgt) # table of P3, P10, P50, P90, P97 of weight for 5-10 year old dutch boys # age per year age <- 5:10 p <- c(0.03,0.1,0.5,0.9,0.97) z <- rep(qnorm(p), length(age)) x <- rep(age, each=length(p)) w <- matrix(z2y(z, x=x, sex="M", ref=nl4.wgt), ncol=length(p), byrow=TRUE) dimnames(w) <- list(age, p) round(w,1) # standard set of Z-scores of weight for all tabulated ages, boys & girls # and three etnicities sds <- c(-2.5, -2, -1, 0, 1, 2, 2.5) age <- nl4.wgt$x z <- rep(sds, times=length(age)) x <- rep(age, each=length(sds)) sex <- rep(c("M","F"), each=length(z)/2) w <- z2y(z=z, x=x, sex=sex, ref=nl4.wgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(age, sds) data.frame(sub=nl4.wgt$sub,sex=nl4.wgt$sex,round(w,2), row.names=NULL) # P85 of BMI in 5-8 year old Dutch boys and girls e <- expand.grid(age=5:8, sex=c("M","F")) w <- z2y(z=rep(qnorm(0.85),nrow(e)), x=e$age, sex=e$sex, ref=nl4.bmi) w <- matrix(w, nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),5:8) w # data transformation of height z-scores to cm-scale z <- c(-1.83, 0.09, 2.33, 0.81, -1.20) x <- c(8.33, 0.23, 19.2, 24.3, 10) sex <- c("M", "M", "F", "M", "F") round(z2y(z=z, x=x, sex=sex, ref=nl4.hgt), 1) # interpolate published height standard # to daily values, days 0-31, boys # on centiles -2SD, 0SD and +2SD days <- 0:31 sds <- c(-2, 0, +2) z <- rep(sds, length(days)) x <- rep(round(days/365.25,4), each=length(sds)) w <- z2y(z, x, sex="M", ref=nl4.hgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(days, sds) w
boys <- boys7482 # SDS of height 115 cm at age 5 years, # relative to Dutch boys reference y2z(y=115, x=5) # same relative to Dutch girls y2z(y=115, x=5, sex="F") # SDS of IOTF BMI cut-off value for overweight (boys 2-18) # relative to Dutch boys reference cutoff <- c( 18.41, 18.15, 17.89, 17.72, 17.55, 17.49, 17.42, 17.49, 17.55, 17.74, 17.92, 18.18, 18.44, 18.77, 19.10, 19.47, 19.84, 20.20, 20.55, 20.89, 21.22, 21.57, 21.91, 22.27, 22.62, 22.96, 23.29, 23.60, 23.90, 24.18, 24.46, 24.73, 25.00) age <- seq(2, 18, by=0.5) (z <- y2z(y=cutoff, x=age, sex="M", ref=nl4.bmi)) # apply inverse transformation to check calculations round(z2y(z, age, ref=nl4.bmi), 2) cutoff # calculate percentiles of weight 12 kg at 2 years (boys, girls) 100*round(pnorm(y2z(y=c(12,12), x=2, sex=c("M","F"), ref=nl4.wgt)),2) # # percentage of children lighter than 15kg at ages 2-5 e <- expand.grid(age=2:5, sex=c("M","F")) z <- y2z(y=rep(15,nrow(e)), x=e$age, sex=e$sex, ref=nl4.wgt) w <- matrix(100*round(pnorm(z),2), nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),2:5) w # analysis in Z scale hgt.z <- y2z(y=boys$hgt, x=boys$age, sex="M", ref=nl4.hgt) wgt.z <- y2z(y=boys$wgt, x=boys$age, sex="M", ref=nl4.wgt) plot(hgt.z, wgt.z, col="blue") # z2y # quantile at SD=0 of age 2 years, # height Dutch boys z2y(z=0, x=2) # same for Dutch girls z2y(z=0, x=2, sex="F") # quantile at SD=c(-1,0,1) of age 2 years, BMI Dutch boys z2y(z=c(-1,0,+1), x=2, ref=nl4.bmi) # 0SD line (P50) in kg of weight for age in 5-10 year, Dutch boys z2y(z=rep(0,6), x=5:10, ref=nl4.wgt) # 95th percentile (P95), age 10 years, wfa, Dutch boys z2y(z=qnorm(0.95), x=10, ref=nl4.wgt) # table of P3, P10, P50, P90, P97 of weight for 5-10 year old dutch boys # age per year age <- 5:10 p <- c(0.03,0.1,0.5,0.9,0.97) z <- rep(qnorm(p), length(age)) x <- rep(age, each=length(p)) w <- matrix(z2y(z, x=x, sex="M", ref=nl4.wgt), ncol=length(p), byrow=TRUE) dimnames(w) <- list(age, p) round(w,1) # standard set of Z-scores of weight for all tabulated ages, boys & girls # and three etnicities sds <- c(-2.5, -2, -1, 0, 1, 2, 2.5) age <- nl4.wgt$x z <- rep(sds, times=length(age)) x <- rep(age, each=length(sds)) sex <- rep(c("M","F"), each=length(z)/2) w <- z2y(z=z, x=x, sex=sex, ref=nl4.wgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(age, sds) data.frame(sub=nl4.wgt$sub,sex=nl4.wgt$sex,round(w,2), row.names=NULL) # P85 of BMI in 5-8 year old Dutch boys and girls e <- expand.grid(age=5:8, sex=c("M","F")) w <- z2y(z=rep(qnorm(0.85),nrow(e)), x=e$age, sex=e$sex, ref=nl4.bmi) w <- matrix(w, nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),5:8) w # data transformation of height z-scores to cm-scale z <- c(-1.83, 0.09, 2.33, 0.81, -1.20) x <- c(8.33, 0.23, 19.2, 24.3, 10) sex <- c("M", "M", "F", "M", "F") round(z2y(z=z, x=x, sex=sex, ref=nl4.hgt), 1) # interpolate published height standard # to daily values, days 0-31, boys # on centiles -2SD, 0SD and +2SD days <- 0:31 sds <- c(-2, 0, +2) z <- rep(sds, length(days)) x <- rep(round(days/365.25,4), each=length(sds)) w <- z2y(z, x, sex="M", ref=nl4.hgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(days, sds) w
Converts standard deviation score (SDS) into measurements using an age- and sex-conditional external reference.
z2y( z = c(-2, 0, 2), x = 1, sex = "M", sub = "N", ref = get("nl4.hgt"), dist = "LMS", dec = 3, sex.fallback = NA, sub.fallback = NA )
z2y( z = c(-2, 0, 2), x = 1, sex = "M", sub = "N", ref = get("nl4.hgt"), dist = "LMS", dec = 3, sex.fallback = NA, sub.fallback = NA )
z |
A numerical vector containing standard deviation scores that are to
be converted. The length |
x |
A vector containing the values of the numerical covariate (typically
decimal age or height) at which conversion is desired. Values are replicated
to match |
sex |
A character vector indicating whether the male ( |
sub |
A character vector indicating the level of the |
ref |
A data frame containing a factor |
dist |
A string identifying the type of distribution. Values values are:
|
dec |
A scalar value indicating the number of decimals used to round the value. |
sex.fallback |
The level of the |
sub.fallback |
The level of the |
Functions z2y()
and y2z()
are the inverse of each other.
The argument dist
determines the statistical distribution. The
possibilities are as follows:
ref
should contain columns mean
and sd
, containing the mean and the
standard deviation in the external reference population.
ref
should contain columns L
, S
and M
containing the LMS parameters.
ref
should contain columns mu
,
sigma
and nu
containing the Box-Cox Cole-Green parameters.
ref
should contain columns mu
,
sigma
, nu
and tau
containing the Box-Cox Power
Exponential parameters.
ref
should contain
columns mu
, sigma
, nu
and tau
containing the
Box-Cox T distribution parameters.
For y2z()
: A vector with length(y)
elements containing
the standard deviation score. For z2y()
: A vector with
length(z)
elements containing quantiles.
Stef van Buuren, 2010
boys <- boys7482 # quantile at SD=0 of age 2 years, # height Dutch boys z2y(z=0, x=2) # same for Dutch girls z2y(z=0, x=2, sex="F") # quantile at SD=c(-1,0,1) of age 2 years, BMI Dutch boys z2y(z=c(-1,0,+1), x=2, ref=nl4.bmi) # 0SD line (P50) in kg of weight for age in 5-10 year, Dutch boys z2y(z=rep(0,6), x=5:10, ref=nl4.wgt) # 95th percentile (P95), age 10 years, wfa, Dutch boys z2y(z=qnorm(0.95), x=10, ref=nl4.wgt) # table of P3, P10, P50, P90, P97 of weight for 5-10 year old dutch boys # age per year age <- 5:10 p <- c(0.03,0.1,0.5,0.9,0.97) z <- rep(qnorm(p), length(age)) x <- rep(age, each=length(p)) w <- matrix(z2y(z, x=x, sex="M", ref=nl4.wgt), ncol=length(p), byrow=TRUE) dimnames(w) <- list(age, p) round(w,1) # standard set of Z-scores of weight for all tabulated ages, boys & girls # and three etnicities sds <- c(-2.5, -2, -1, 0, 1, 2, 2.5) age <- nl4.wgt$x z <- rep(sds, times=length(age)) x <- rep(age, each=length(sds)) sex <- rep(c("M","F"), each=length(z)/2) w <- z2y(z=z, x=x, sex=sex, ref=nl4.wgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(age, sds) data.frame(sub=nl4.wgt$sub,sex=nl4.wgt$sex,round(w,2), row.names=NULL) # P85 of BMI in 5-8 year old Dutch boys and girls e <- expand.grid(age=5:8, sex=c("M","F")) w <- z2y(z=rep(qnorm(0.85),nrow(e)), x=e$age, sex=e$sex, ref=nl4.bmi) w <- matrix(w, nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),5:8) w # data transformation of height z-scores to cm-scale z <- c(-1.83, 0.09, 2.33, 0.81, -1.20) x <- c(8.33, 0.23, 19.2, 24.3, 10) sex <- c("M", "M", "F", "M", "F") round(z2y(z=z, x=x, sex=sex, ref=nl4.hgt), 1) # interpolate published height standard # to daily values, days 0-31, boys # on centiles -2SD, 0SD and +2SD days <- 0:31 sds <- c(-2, 0, +2) z <- rep(sds, length(days)) x <- rep(round(days/365.25,4), each=length(sds)) w <- z2y(z, x, sex="M", ref=nl4.hgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(days, sds) w
boys <- boys7482 # quantile at SD=0 of age 2 years, # height Dutch boys z2y(z=0, x=2) # same for Dutch girls z2y(z=0, x=2, sex="F") # quantile at SD=c(-1,0,1) of age 2 years, BMI Dutch boys z2y(z=c(-1,0,+1), x=2, ref=nl4.bmi) # 0SD line (P50) in kg of weight for age in 5-10 year, Dutch boys z2y(z=rep(0,6), x=5:10, ref=nl4.wgt) # 95th percentile (P95), age 10 years, wfa, Dutch boys z2y(z=qnorm(0.95), x=10, ref=nl4.wgt) # table of P3, P10, P50, P90, P97 of weight for 5-10 year old dutch boys # age per year age <- 5:10 p <- c(0.03,0.1,0.5,0.9,0.97) z <- rep(qnorm(p), length(age)) x <- rep(age, each=length(p)) w <- matrix(z2y(z, x=x, sex="M", ref=nl4.wgt), ncol=length(p), byrow=TRUE) dimnames(w) <- list(age, p) round(w,1) # standard set of Z-scores of weight for all tabulated ages, boys & girls # and three etnicities sds <- c(-2.5, -2, -1, 0, 1, 2, 2.5) age <- nl4.wgt$x z <- rep(sds, times=length(age)) x <- rep(age, each=length(sds)) sex <- rep(c("M","F"), each=length(z)/2) w <- z2y(z=z, x=x, sex=sex, ref=nl4.wgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(age, sds) data.frame(sub=nl4.wgt$sub,sex=nl4.wgt$sex,round(w,2), row.names=NULL) # P85 of BMI in 5-8 year old Dutch boys and girls e <- expand.grid(age=5:8, sex=c("M","F")) w <- z2y(z=rep(qnorm(0.85),nrow(e)), x=e$age, sex=e$sex, ref=nl4.bmi) w <- matrix(w, nrow=2, byrow=TRUE) dimnames(w) <- list(c("boys","girls"),5:8) w # data transformation of height z-scores to cm-scale z <- c(-1.83, 0.09, 2.33, 0.81, -1.20) x <- c(8.33, 0.23, 19.2, 24.3, 10) sex <- c("M", "M", "F", "M", "F") round(z2y(z=z, x=x, sex=sex, ref=nl4.hgt), 1) # interpolate published height standard # to daily values, days 0-31, boys # on centiles -2SD, 0SD and +2SD days <- 0:31 sds <- c(-2, 0, +2) z <- rep(sds, length(days)) x <- rep(round(days/365.25,4), each=length(sds)) w <- z2y(z, x, sex="M", ref=nl4.hgt) w <- matrix(w, ncol=length(sds), byrow=TRUE) dimnames(w) <- list(days, sds) w