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

View source: R/LMS2z.R

LMS2zR Documentation

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, LMStable = FALSE)

Arguments

x

vector of ages in units of years.

y

vector or one-column matrix of either measurements or z-scores, depending on the value of toz.

sex

vector where 1/2 = males/females = boys/girls = TRUE/FALSE, based on the uppercased first character of the string.

measure

unique measurement name, as character string, the choice depending on the choice of ref (see e.g. references uk90, who06 and ukwhopt).

ref

unique growth reference, either as name or character string, available as a data object or data frame (e.g. uk90, who06 or ukwhopt).

toz

logical set to TRUE for conversion from measurement to z-score, or FALSE for the reverse.

LMStable

logical set to TRUE to return the associated LMS table as a data frame in attribute LMStable.

Details

Growth references fitted by the LMS method consist of a table of L, M and S values by age and sex. Vectors of L, M and S corresponding to x and sex are extracted using cubic interpolation and passed to either cLMS or zLMS, depending on toz.

Disjunct references are supported, where there is a disjunction in the centiles at a particular age. This may be because the measurement changes, e.g. from length to height, or because two different references have been joined together. The disjunction is flagged by including two rows at the common age, but with different L, M and S values, and measurements at this age are ascribed to the older reference. For example the who06 reference has a disjunction at 2 years reflecting the switch from length to height. As a result height at just below and just above 2 years returns a different z-score.

Value

A vector or matrix containing the transformed values. If y is a vector then a vector of length(x) is returned, else if y is a one-column matrix then a matrix is returned, with length(x) rows and length(y) columns. The matrix row names are set to x, and the column names to either y or if toz is FALSE, z2cent(y). If LMStable is TRUE the associated LMS table is returned as a data frame in attribute LMStable.

Author(s)

Tim Cole tim.cole@ucl.ac.uk

See Also

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

Examples


## 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 9 centiles
ages <- 0:20/4 # 3-month ages to 5 years
LMS2z(ages, as.matrix(zs), sex = 'm', measure = 'wt', ref = who06,
  toz = FALSE, LMStable = TRUE)


sitar documentation built on July 9, 2023, 6:51 p.m.