LMS2z | R Documentation |
A function to convert between measurements and z-scores using a growth reference previously fitted by the LMS method.
LMS2z(x, y, sex, measure, ref, toz = TRUE, LMStable = FALSE)
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 |
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 |
unique growth reference, either as name or character string, available as
a |
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 |
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.
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
.
Tim Cole tim.cole@ucl.ac.uk
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.