centilesLMS: Interpolate Centile or LMS tables

Description Usage Arguments Details Value See Also Examples

View source: R/functions.R

Description

These functions are useful for producing reference tables or plots. centilesLMS produces a table of centiles. getLMS produces a table of interpolated LMS values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
getLMS(
  x,
  sex,
  LMS,
  xname = "x",
  method = c("fmm", "periodic", "natural", "monoH.FC", "hyman", "linear", "constant"),
  rule = 1
)

centilesLMS(
  x,
  sex,
  LMS,
  cent = c(0.02, 0.05, 0.25, 0.5, 0.75, 0.95, 0.98),
  xname = "x",
  method = c("fmm", "periodic", "natural", "monoH.FC", "hyman", "linear", "constant"),
  rule = 1
)

Arguments

x

a single value or vector of either ages in years or height in cm at which to interpolate LMS of centile values.

sex

a single value or vector of sexes. Sex must be coded for males/females as 1/0, 1/2, 'm'/'f', 'M'/'F', 'Male'/'Female', or 'male'/'female'.

LMS

a data frame containing the LMS table with columns named "Sex","Age","Lambda","Mu", "Sigma" or "Sex","Height","Lambda","Mu","Sigma". Internal LMS tables can be referenced by pop.type, i.e. CDC.Height

xname

optional name to give the x column in the output, typically "Age" or "Height".

method

the interpolation method. If it is "fmm", "periodic", "natural", "monoH.FC", or "hyman", splinefun is used. If method is "linear" or "constant", approxfun is used.

rule

an integer (of length 1 or 2) describing how interpolation is to take place outside the interval [min(x), max(x)]. If rule is 1 then NAs are returned. If rule is 2 and method is "linear" or "constant", then rule is followed as in approxfun. If rule is 2 and a spline is used, the spline will be used to extrapolate outside the interval. If rule is length 2 (i.e c(2,1)), then different rules will be used for the left and right side extrapolation.

cent

a single value or vector of centiles

Details

getLMS produces a table of LMS values interpolated at the specified x values. Interpolation is done using either splinefun or approxfun, as determined by the method parameter. By default, observations outside the range of the reference LMS are returned as NA, but this can be overridden to allow for extrapolation by setting the rule parameter. See approxfun. centilesLMS uses getLMS to produce the appropriate LMS tabel, and then calculates the values at the centiles specified by cent

Value

Returns a data frame with columns corresponding to the provided x-value and columns for either Lambda, Mu, and Sigma (for getLMS), or the requested centiles (for centilesLMS).

See Also

ZfromLMS, growthRef, getZ

Examples

1
2
3
4
5
#Produce a Tsimane height LMS table for males at ages 0-10
LMS<-getLMS(0:10,"Male",Tsimane.Height,xname="Age")

#Produce a Tsimane height centile table for males at ages 0-10
cent<-centilesLMS(0:10,"Male",Tsimane.Height,cent=c(0.025,0.5,0.975),xname="Age")

adblackwell/localgrowth documentation built on Jan. 26, 2020, 4:43 p.m.