sitar (version 1.0.9)

LMS2z: Convert to/from measurement from/to z-score with growth reference

Description

A function to convert between measurements and z-scores using a growth reference previously fitted by the LMS method.

Usage

LMS2z(x, y, sex, measure, ref, toz = TRUE)

Arguments

x
vector of ages.
y
vector of either measurements or z-scores, depending on the value of toz.
sex
two-level factor with level 1 male and level 2 female, of length one or length(x).
measure
character indicating the name of the measurement, depending on the choice of ref (see e.g. references uk90, who06 and ukwhopt).
ref
character indicating the name of the growth reference, available as a data object.
toz
logical set to TRUE for conversion from measurement to z-score, or FALSE for the reverse.

Value

A vector or matrix, depending on the lengths of x and y, containing the transformed values. If the two lengths are the same, or either is one, then a vector is returned. If they are different and not one, then a matrix with length(x) rows and length(y) columns is returned. In this latter case the row names are set to x, and if toz is false the column names are set using z2cent.

Details

Vectors of L, M and S corresponding to x and sex are extracted and passed to either cLMS or zLMS, depending on toz.

See Also

z2cent. The LMS method can be fitted to data using the package gamlss with the BCCG family, where nu (originally lambda), mu and sigma correspond to L, M and S respectively.

Examples

Run this code

## convert girls' heights data to UK 90 z-scores
data(heights)
data(uk90)
with(heights, LMS2z(age, height, sex = 2, measure = 'ht', ref = 'uk90'))

## construct table of boys weight centiles by age for WHO standard
data(who06)
zs <- -4:4*2/3 # z-scores for centiles
ages <- 0:12/4 # 3-month ages
v <- as.data.frame(lapply(as.list(zs), function(z) {
  v <- LMS2z(ages, z, sex = 1, measure = 'wt', ref = 'who06', toz = FALSE)
}))
names(v) <- z2cent(zs)
rownames(v) <- ages
round(v, 2)

Run the code above in your browser using DataLab