sitar (version 1.1.0)

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

Arguments

x

vector of ages.

y

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

sex

vector where males = 1 and females = 2.

measure

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

ref

growth reference, either as name or character string, available as a data object or data frame.

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.

Value

A vector or matrix containing the transformed values. If y is a vector then a vector 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.

Details

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.

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

Run this code
# NOT RUN {
## 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
LMS2z(ages, as.matrix(zs), sex = 1, measure = wt, ref = who06, toz = FALSE)

# }

Run the code above in your browser using DataCamp Workspace