Healthy birth, growth & development

Authors: Ryan Hafen [aut, cre],Craig Anderson [ctb]

Version: 0.3.2

License: MIT + file LICENSE

Description

A package for visual and analytical methods for the analysis of longitudinal growth data.

Depends

R (>= 3.1), datadr (>= 0.8.1), trelliscope (>= 0.9.2)

Imports

dplyr, lattice, rbokeh (>= 0.3.4), ggplot2, mgcv, MASS, numDeriv, gamlss.dist, fda, face (>= 0.1-2), brokenstick (>= 0.16), sitar (>= 1.0.3), DT, lme4, nlme, scales, crayon, stringdist

Suggests

testthat

Enhances

(none)

Data Handling

check_data

Check a dataset to ensure it will be compatible with hbgd methods

Usage

check_data(dat, has_height = TRUE, has_weight = TRUE, has_hcir = TRUE)

Arguments

dat
a data frame
has_height
does this data set contain anthropometric height data?
has_weight
does this data set contain anthropometric weight data?
has_hcir
does this data set contain anthropometric head circumference data?

Examples

check_data(cpp, has_hcir = FALSE)

smc <- brokenstick::smocc.hgtwgt
check_data(smc, has_hcir = FALSE)

names(smc)[2] <- "subjid"
names(smc)[5] <- "agedays"
smc$sex <- as.character(smc$sex)
smc$sex[smc$sex == "male"] <- "Male"
smc$sex[smc$sex == "female"] <- "Female"
names(smc)[10] <- "htcm"
names(smc)[11] <- "wtkg"

check_data(smc, has_hcir = FALSE)

names(smc)[12] <- "haz"
smc$waz <- who_wtkg2zscore(smc$agedays, smc$wtkg, smc$sex)
smc$agedays <- smc$agedays * 365.25

check_data(smc, has_hcir = FALSE)

get_subject_data

Get subject-level or time-varying variables and rows of longitudinal data

Arguments

dat
data frame with longitudinal data

get_time_data

Get subject-level or time-varying variables and rows of longitudinal data

Arguments

dat
data frame with longitudinal data

fix_height

Merge htcm and lencm into one variable

Usage

fix_height(dat, height_var = "htcm", length_var = "lencm",
  target = "htcm")

Arguments

dat
data
height_var
name of height variable
length_var
name of length variable
target
name of target variable to hold the merged variable

add_holdout_ind

Add indicator column for per-subject holdout

Usage

add_holdout_ind(dat, random = TRUE)

Arguments

dat
data
random
if TRUE, a random observation per subject will be designated as the holdout, if FALSE, the endpoint for each subject will be designated as the holdout

view_variables

View known hbgd variables

Usage

view_variables()

get_data_attributes

Infer and attach attributes to a longitudinal growth study data set

Infer attributes such as variable types of a longitudinal growth study and add as attributes to the data set.

Usage

get_data_attributes(dat, meta = NULL, study_meta = NULL)

Arguments

dat
a longitudinal growth study data set
meta
a data frame of meta data about the variables (a row for each variable)
study_meta
a single-row data frame or named list of meta data about the study (such as study description, etc.)

Details

attributes added: - subjectlevel_vars: vector of names of subject-level variables - timevarying_vars: vector of names of time-varying variables - time_vars: vector of names of measures of age - var_summ: data frame containing variable summaries with columns variable, label, type[subject id, time indicator, time-varying, constant], n_unique - subj_count: data frame of counts of records for each subject with columns subjid, n - n_subj: scalar containing total number of subjects - labels named list of variable labels - either populated by matching names with a pre-set list of labels (see hbgd_labels) or from a list provided from the meta argument - study_meta: data frame of meta data (if provided from the study_meta argument) - short_id: scalar containing the short unique identifier for the study (if study_meta is provided)

Examples

cpp <- get_data_attributes(cpp)
str(attributes(cpp))

See also

get_data_attributes

WHO Growth Standards

who_wtkg2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_htcm2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_bmi2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_hcircm2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_muaccm2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_ss2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_tsftmm2zscore

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_wtkg2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_htcm2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_bmi2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_hcircm2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_muaccm2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_ss2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_tsftmm2centile

Convert anthro measurements to WHO z-scores/centiles

Arguments

agedays
age in days
wtkg
weight (kg) measurement(s) to convert
sex
“Male” or “Female”
htcm
height(cm) measurement(s) to convert
bmi
body-mass index measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert
muaccm
mid-upper arm circumference (cm) measurement(s) to convert
ss
subscalpular skinfold (cm) measurement(s) to convert
tsftmm
triceps skinfold (mm) measurement(s) to convert

who_value2zscore

Convert anthro measurements to WHO z-scores/centiles (generic)

Compute z-scores or centiles with respect to the WHO growth standard for given values of x vs. y (typically x is “agedays” and y is a measure like “htcm”).

Usage

who_value2zscore(x, y, x_var = "agedays", y_var = "htcm", sex = "Female",
  data = NULL)

who_value2centile(x, y, x_var = "agedays", y_var = "htcm", sex = "Female")

Arguments

x
value or vector of values that correspond to a measure defined by x_var
y
value or vector of values that correspond to a measure defined by y_var
x_var
x variable name (typically “agedays”) - see details
y_var
y variable name (typically “htcm” or “wtkg”) - see details
sex
“Male” or “Female”
data
optional data frame that supplies any of the other variables provided to the function

Details

for all supported pairings of x_var and y_var, type names(who)

Examples

# z-scores
who_value2zscore(1670, in2cm(44))
who_value2zscore(1670, lb2kg(48), y_var = "wtkg")

who_value2centile(1670, in2cm(44))
who_value2centile(1670, lb2kg(48), y_var = "wtkg")

# add haz derived from WHO data and compare to that provided with data
cpp$haz2 <- who_value2zscore(x = agedays,  y = lencm, sex = sex, data = cpp)
plot(cpp$haz, cpp$haz2)

# note that you can also do it this way
#' cpp$haz2 <- who_value2zscore(cpp$agedays, cpp$lencm, sex = cpp$sex)

See also

who_centile2value, who_zscore2value

who_zscore2value

Convert WHO z-scores/centiles to anthro measurements (generic)

Get values of a specified measurement for a given WHO centile/z-score and growth standard pair (e.g. length vs. age) and sex over a specified grid

Arguments

x
vector specifying the values of x over which to provide the centiles for y
p
centile or vector of centiles at which to compute values (a number between 0 and 100 - 50 is median)
x_var
x variable name (typically “agedays”) - see details
y_var
y variable name (typically “htcm” or “wtkg”) that specifies which variable of values should be returned for the specified value of q - see details
sex
“Male” or “Female”
data
optional data frame that supplies any of the other variables provided to the function
z
z-score or vector of z-scores at which to compute values

Details

for all supported pairings of x_var and y_var, type names(who)

See also

who_value2centile, who_value2zscore

who_value2centile

Convert anthro measurements to WHO z-scores/centiles (generic)

Compute z-scores or centiles with respect to the WHO growth standard for given values of x vs. y (typically x is “agedays” and y is a measure like “htcm”).

Arguments

x
value or vector of values that correspond to a measure defined by x_var
y
value or vector of values that correspond to a measure defined by y_var
x_var
x variable name (typically “agedays”) - see details
y_var
y variable name (typically “htcm” or “wtkg”) - see details
sex
“Male” or “Female”
data
optional data frame that supplies any of the other variables provided to the function

Details

for all supported pairings of x_var and y_var, type names(who)

See also

who_centile2value, who_zscore2value

who_centile2value

Convert WHO z-scores/centiles to anthro measurements (generic)

Get values of a specified measurement for a given WHO centile/z-score and growth standard pair (e.g. length vs. age) and sex over a specified grid

Usage

who_centile2value(x, p = 50, x_var = "agedays", y_var = "htcm",
  sex = "Female", data = NULL)

who_zscore2value(x, z = 0, y_var = "htcm", x_var = "agedays",
  sex = "Female", data = NULL)

Arguments

x
vector specifying the values of x over which to provide the centiles for y
p
centile or vector of centiles at which to compute values (a number between 0 and 100 - 50 is median)
x_var
x variable name (typically “agedays”) - see details
y_var
y variable name (typically “htcm” or “wtkg”) that specifies which variable of values should be returned for the specified value of q - see details
sex
“Male” or “Female”
data
optional data frame that supplies any of the other variables provided to the function
z
z-score or vector of z-scores at which to compute values

Details

for all supported pairings of x_var and y_var, type names(who)

Examples

# median height vs. age for females
x <- seq(0, 365, by = 7)
med <- who_centile2value(x)
plot(x, med, xlab = "age in days", ylab = "median female height (cm)")

# 99th percentile of weight vs. age for males from age 0 to 1461 days
dat <- data.frame(x = rep(seq(0, 1461, length = 100), 2),
  sex = rep(c("Male", "Female"), each = 100))
dat$p99 <- who_centile2value(x, p = 99, y_var = "wtkg", sex = sex, data = dat)
lattice::xyplot(kg2lb(p99) ~ days2years(x), groups = sex, data = dat,
  ylab = "99th percentile weight (pounds) for males",
  xlab = "age (years)", auto.key = TRUE)

See also

who_value2centile, who_value2zscore

Intergrowth Birth Standards

igb_lencm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_wtkg2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_hcircm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_lencm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_wtkg2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_hcircm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagebrth
gestational age at birth in days
lencm
length(cm) measurement(s) to convert
sex
“Male” or “Female”
wtkg
weight (kg) measurement(s) to convert
hcircm
head circumference (cm) measurement(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_value2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Usage

igb_value2centile(gagebrth, val, var = "lencm", sex = "Female")

igb_value2zscore(gagebrth, val, var = "lencm", sex = "Female")

Arguments

gagebrth
gestational age at birth in days
val
the value(s) of the anthro measurement to convert
var
the name of the measurement to convert (“lencm”, “wtkg”, “hcircm”)
sex
“Male” or “Female”

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

Examples

# get Male birth length z-scores
# first we need just 1 record per subject with subject-level data
cppsubj <- get_subject_data(cpp)
cppsubj <- subset(cppsubj, sex == "Male")
igb_value2zscore(cpp$gagebrth, cpp$birthlen, var = "lencm", sex = "Male")

igb_zscore2value

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Usage

igb_centile2value(gagebrth, p = 50, var = "lencm", sex = "Female")

igb_zscore2value(gagebrth, z = 0, var = "lencm", sex = "Female")

Arguments

gagebrth
gestational age at birth in days
p
centile(s) to convert (must be between 0 and 100)
var
the name of the measurement to convert (“lencm”, “wtkg”, “hcircm”)
sex
“Male” or “Female”
z
z-score(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

Examples

# get 99th centile for Male birth weights across some gestational ages
igb_centile2value(232:300, 99, var = "wtkg", sex = "Male")

igb_value2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Arguments

gagebrth
gestational age at birth in days
val
the value(s) of the anthro measurement to convert
var
the name of the measurement to convert (“lencm”, “wtkg”, “hcircm”)
sex
“Male” or “Female”

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

igb_centile2value

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Arguments

gagebrth
gestational age at birth in days
p
centile(s) to convert (must be between 0 and 100)
var
the name of the measurement to convert (“lencm”, “wtkg”, “hcircm”)
sex
“Male” or “Female”
z
z-score(s) to convert

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

Intergrowth Prenatal Standards

igpre_hccm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_bpdcm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_ofdcm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_accm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_flcm2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_hccm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_bpdcm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_ofdcm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_accm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_flcm2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles

Arguments

gagedays
gestational age in days
hccm
head circumference (cm) measurement(s) to convert
bpdcm
biparietel diameter (cm) measurement(s) to convert
ofdcm
occipito-frontal diameter (cm) measurement(s) to convert
accm
abdominal circumference (cm) measurement(s) to convert
flcm
femur length (cm) measurement(s) to convert

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_value2zscore

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Usage

igpre_value2zscore(gagedays, val, var = c("hccm", "bpdcm", "ofdcm", "accm",
  "flcm"))

igpre_value2centile(gagedays, val, var = c("hccm", "bpdcm", "ofdcm", "accm",
  "flcm"))

Arguments

gagedays
gestational age in days
val
the value(s) of the anthro measurement to convert
var
the name of the measurement to convert (“hccm”, “bpdcm”, “ofdcm”, “accm”, “flcm”)

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

Examples

# get centile for child at 100 gestational days with 11 cm head circumference
igpre_hccm2centile(100, 11)

igpre_zscore2value

Convert Intergrowth z-scores/centiles to prenatal ultrasound measurements (generic)

Usage

igpre_zscore2value(gagedays, z = 0, var = c("hccm", "bpdcm", "ofdcm",
  "accm", "flcm"))

igpre_centile2value(gagedays, p = 50, var = c("hccm", "bpdcm", "ofdcm",
  "accm", "flcm"))

Arguments

gagedays
gestational age in days
z
z-score(s) to convert
var
the name of the measurement to convert (“hccm”, “bpdcm”, “ofdcm”, “accm”, “flcm”)
p
centile(s) to convert (must be between 0 and 100)

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

Examples

# get value for median head circumference for child at 100 gestational days
igpre_centile2value(100, 50, var = "hccm")

igpre_value2centile

Convert prenatal ultrasound measurements to Intergrowth z-scores/centiles (generic)

Arguments

gagedays
gestational age in days
val
the value(s) of the anthro measurement to convert
var
the name of the measurement to convert (“hccm”, “bpdcm”, “ofdcm”, “accm”, “flcm”)

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

igpre_centile2value

Convert Intergrowth z-scores/centiles to prenatal ultrasound measurements (generic)

Arguments

gagedays
gestational age in days
z
z-score(s) to convert
var
the name of the measurement to convert (“hccm”, “bpdcm”, “ofdcm”, “accm”, “flcm”)
p
centile(s) to convert (must be between 0 and 100)

References

International standards for fetal growth based on serial ultrasound measurements: the Fetal Growth Longitudinal Study of the INTERGROWTH-21st Project Papageorghiou, Aris T et al. The Lancet, Volume 384, Issue 9946, 869-879

Growth Standard Vis

ly_who

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

ly_igb

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

ly_igpre

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

ly_zband

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

fig
rbokeh figure to add z bands to
x
range on x axis that should be covered by bands
z
z-scores at which to draw bands (only need to specify on one side of zero)
color
color to use for bands
alpha
transparency of the bands
obj
ggplot2 object to add z bands to

panel.who

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

panel.igb

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

panel.igpre

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

panel.zband

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

fig
rbokeh figure to add z bands to
x
range on x axis that should be covered by bands
z
z-scores at which to draw bands (only need to specify on one side of zero)
color
color to use for bands
alpha
transparency of the bands
obj
ggplot2 object to add z bands to

geom_who

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

geom_igb

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

geom_igpre

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

x
value or vector of values that correspond to a measure defined by x_var
x_var
x variable name (typically “agedays”)
y_var
y variable name (typically “htcm” or “wtkg”)
sex
“Male” or “Female”
p
centiles at which to draw the growth standard band polygons (only need to specify on one side of the median)
color
optional color to use for bands (will use sex to determine if not specified)
alpha
transparency of the bands
center
should the bands be centered around the median?
labels
should the centiles be labeled? (not implemented)
x_trans
transformation function to be applied to x-axis
y_trans
transformation function to be applied to y-axis
gagebrth
gestational age at birth in days (for igb plots)
var
variable name for y axis for igb or igpre plots (“lencm”, “wtkg”, or “hcircm” for igb; “accm”, “bpdcm”, “flcm”, “hccm”, or “ofdcm” for igpre)
gagedays
gestational age in days (for igpre plots)
obj
ggplot2 object to add growth standard to
fig
rbokeh figure to add growth standard to

geom_zband

Utility functions for adding growth standard bands to rbokeh/lattice/ggplot2 plots

Arguments

fig
rbokeh figure to add z bands to
x
range on x axis that should be covered by bands
z
z-scores at which to draw bands (only need to specify on one side of zero)
color
color to use for bands
alpha
transparency of the bands
obj
ggplot2 object to add z bands to

Modeling

get_fit

Obtain a trajectory “fit” object for a data set

Usage

get_fit(dat, x_var = "agedays", y_var = "htcm", method = "fda",
  holdout = FALSE, x_trans = NULL, x_inv = NULL, y_trans = NULL,
  y_inv = NULL, ...)

Arguments

dat
data frame containing variables to model
x_var
name of x variable to model (default is “agedays”)
y_var
name of y variable to model (usually an anthropometric measure or z-score scaled anthropometric measure)
method
name of fitting method to use (see get_avail_methods)
holdout
should an observation be held out for fitting (will use column hold in dat to which observations to hold out)
x_trans, y_trans
transformation functions to be applied to x and y prior to modeling
x_inv, y_inv
inverse transformation functions for x and y to get back to the original scale after modeling
parameters passed on to the fitting method

fit_trajectory

Apply a model fit to an individual’s trajectory

Usage

fit_trajectory(dat, fit, xg = NULL, checkpoints = 365 * c(1:2),
  z_bins = -2)

Arguments

dat
data frame containing variables for one subject to apply a fit to
fit
an object returned from get_fit
xg
grid of x points at which the fit should be evaluated for plotting (if NULL it will be set to an equally-spaced grid of 150 points across x)
checkpoints
x values at which to compute “checkpoints” of the subjectss growth trajectory to compare to other subjects
z_bins
a vector indicating binning of z-scores for the subjects trajectory at each checkpoint with respect to the the WHO growth standard

Examples

mod <- get_fit(cpp, y_var = "wtkg")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot(fit$xy$x, fit$xy$y)
lines(fit$fitgrid$x, fit$fitgrid$y)
# there is also a plot method:
plot(fit, x_range = c(0, 2560))
# we can fit the z-scores instead
mod2 <- get_fit(cpp, y_var = "waz")
fit2 <- fit_trajectory(subset(cpp, subjid == 2), mod2)
plot(fit2$xy$x, fit2$xy$z)
lines(fit2$fitgrid$x, fit2$fitgrid$z)

fit_all_trajectories

Apply trajectory fitting to each subject in a data set

Usage

fit_all_trajectories(dat, fit, xg = NULL, checkpoints = 365 * c(1:2),
  z_bins = -2)

Arguments

dat
a data frame containing data for several subjects or a ddf already divided by subject, as obtained from by_subject
fit
an object returned from get_fit
xg
grid of x points at which the fit should be evaluated for plotting (if NULL it will be set to an equally-spaced grid of 150 points across x)
checkpoints
x values at which to compute “checkpoints” of the subjectss growth trajectory to compare to other subjects
z_bins
a vector indicating binning of z-scores for the subjects trajectory at each checkpoint with respect to the the WHO growth standard

Examples

cppfit <- get_fit(cpp, y_var = "wtkg", method = "rlm")
cpptr  <- fit_all_trajectories(cpp, cppfit)
cpptr[[1]]
plot(cpptr[[1]]$value)

get_fit_holdout_mse

Get MSE for holdout

Usage

get_fit_holdout_mse(d, z = TRUE)

Arguments

d
an object returned from fit_all_trajectories
z
compute MSE on z-score scale or original scale?

plot.fittedTrajectory

Plot a fitted trajectory

Usage

plotfittedTrajectory(x, center = FALSE, x_range = NULL,
  width = 500, height = 520, hover = NULL, checkpoints = TRUE, p = 100
  * pnorm(-3:0), ...)

Arguments

x
an object returned from fit_trajectory
center
should the trajectory be centered around the median WHO standard? This is equivalent to plotting the age difference score (like height-for-age difference - HAD)
x_range
a vector specifying the range (min, max) that the superposed growth standard should span on the x-axis
width
width of the plot
height
height of the plot
hover
variable names in x$data to show on hover for each point (only variables with non-NA data will be shown)
checkpoints
should the checkpoints be plotted (if available)?
p
centiles at which to draw the WHO polygons
additional parameters passed to figure

Examples

mod <- get_fit(cpp, y_var = "wtkg", method = "rlm")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot(fit)
plot(fit, center = TRUE)
plot(fit, hover = c("wtkg", "bmi", "waz", "haz"))

plot_z

Plot a fitted trajectory on z-score scale

Usage

plot_z(x, x_range = NULL, nadir = FALSE, width = 500, height = 520,
  hover = NULL, checkpoints = TRUE, z = -3:0, ...)

Arguments

x
an object returned from fit_trajectory
x_range
a vector specifying the range (min, max) that the superposed z-score bands should span on the x-axis
nadir
should a guide be added to the plot showing the location of the nadir?
width
width of the plot
height
height of the plot
hover
variable names in x$data to show on hover for each point (only variables with non-NA data will be shown)
checkpoints
should the checkpoints be plotted (if available)?
z
z-scores at which to draw the z-score bands
additional parameters passed to figure

Examples

mod <- get_fit(cpp, y_var = "wtkg", method = "rlm")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot_z(fit)

plot_velocity

Plot a fitted trajectory’s velocity

Usage

plot_velocity(x, width = 500, height = 520, ...)

Arguments

x
an object returned from fit_trajectory
width
width of the plot
height
height of the plot
additional parameters passed to figure

Examples

mod <- get_fit(cpp, y_var = "wtkg", method = "rlm")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot_velocity(fit)

plot_zvelocity

Plot a fitted trajectory’s z-score velocity

Usage

plot_zvelocity(x, width = 500, height = 520, ...)

Arguments

x
an object returned from fit_trajectory
width
width of the plot
height
height of the plot
additional parameters passed to figure

Examples

mod <- get_fit(cpp, y_var = "wtkg", method = "rlm")
fit <- fit_trajectory(subset(cpp, subjid == 2), mod)
plot_zvelocity(fit)

get_avail_methods

Get names of all available fitting methods

Usage

get_avail_methods()

See also

get_fit

fit_method.gam

Compute gam spline fit of growth trajectory

Usage

fit_methodgam(dat, ...)

Arguments

dat
data frame specifying x and y coordinates of data to fit
additional parameters passed to gam

Note

The trajectory fitting functions are most easily accessed through calling fit_trajectory with the method argument to specify the modeling approach to use.

These fitting functions can easily be replaced by simply calling the associated R methods, but are provided for convenience to standardize input/output to simplify swapping fitting methods.

fit_method.loess

Compute loess fit of growth trajectory

Usage

fit_methodloess(dat, ...)

Arguments

dat
data frame specifying x and y coordinates of data to fit
additional parameters passed to loess, notably span, degree, and family

Note

The trajectory fitting functions are most easily accessed through calling fit_trajectory with the method argument to specify the modeling approach to use.

These fitting functions can easily be replaced by simply calling the associated R methods, but are provided for convenience to standardize input/output to simplify swapping fitting methods.

fit_method.rlm

Compute robust linear model fit of growth trajectory

Usage

fit_methodrlm(dat, ...)

Arguments

dat
data frame specifying x and y coordinates of data to fit
additional parameters passed to rlm, also p which is the order of polynomial fit (default is quadratic, p=2)

Note

The trajectory fitting functions are most easily accessed through calling fit_trajectory with the method argument to specify the modeling approach to use.

These fitting functions can easily be replaced by simply calling the associated R methods, but are provided for convenience to standardize input/output to simplify swapping fitting methods.

fit_method.fda

Compute functional “fda” fit of growth trajectory

Usage

fit_methodfda(dat, ...)

Arguments

dat
data frame specifying x and y coordinates of data to fit
additional parameters passed to smooth.basisPar, notably lambda which defaults to 0.1

Note

The trajectory fitting functions are most easily accessed through calling fit_trajectory with the method argument to specify the modeling approach to use.

These fitting functions can easily be replaced by simply calling the associated R methods, but are provided for convenience to standardize input/output to simplify swapping fitting methods.

fit_method.brokenstick

Get the result of fitting brokenstick to a data set

Usage

fit_methodbrokenstick(dat, ...)

Arguments

dat
data frame containing variables to model
additional parameters passed to brokenstick, most notably knots

Details

This essentially gets an anthropometric data set into shape for brokenstick (sets appropriate data structure and removes missing values) and runs the fitting routine.

Note

The settings for x_trans and y_trans must match that used in fit_trajectory and appropriate inverse transformations must be set there accordingly as well.

Examples

bsfit <- get_fit(cpp, y_var = "haz", method = "brokenstick")
fit <- fit_trajectory(subset(cpp, subjid == 2), fit = bsfit)
plot(fit)

fit_method.lwmod

Get the result of fitting a Laird and Ware linear or quadratic model to a data set

Usage

fit_methodlwmod(dat, ...)

Arguments

dat
data frame containing variables to model
additional parameters, most notably deg which controls the degree of polynomial for the fit (1 for linear and 2 for quadratic)

Details

This essentially gets an anthropometric data set into shape for sitar (sets appropriate data structure and removes missing values) and runs the fitting routine.

Note

The settings for x_trans and y_trans must match that used in fit_trajectory and appropriate inverse transformations must be set there accordingly as well.

Examples

lwfit <- get_fit(cpp, y_var = "haz", method = "lwmod", deg = 2)
fit <- fit_trajectory(subset(cpp, subjid == 2), fit = lwfit)
plot(fit)

fit_method.sitar

Get the result of fitting sitar to a data set

Usage

fit_methodsitar(dat, ...)

Arguments

dat
data frame containing variables to model
additional parameters passed to sitar, most notably df which defaults to 3

Details

This essentially gets an anthropometric data set into shape for sitar (sets appropriate data structure and removes missing values) and runs the fitting routine.

Note

The settings for x_trans and y_trans must match that used in fit_trajectory and appropriate inverse transformations must be set there accordingly as well.

Examples

sitfit <- get_fit(cpp, y_var = "haz", method = "sitar")
fit <- fit_trajectory(subset(cpp, subjid == 2), fit = sitfit)
plot(fit)

fit_method.smooth.spline

Compute smooth.spline fit of growth trajectory

Usage

fit_methodsmooth.spline(dat, ...)

Arguments

dat
data frame specifying x and y coordinates of data to fit
additional parameters passed to smooth.spline

Note

The trajectory fitting functions are most easily accessed through calling fit_trajectory with the method argument to specify the modeling approach to use.

These fitting functions can easily be replaced by simply calling the associated R methods, but are provided for convenience to standardize input/output to simplify swapping fitting methods.

fit_method.wand

Get the result of fitting a “Wand” model to a data set

Usage

fit_methodwand(dat, ...)

Arguments

dat
data frame containing variables to model
additional parameters, most notably deg which controls the degree of polynomial for the fit (1 for linear and 2 for quadratic)

Details

This essentially gets an anthropometric data set into shape for sitar (sets appropriate data structure and removes missing values) and runs the fitting routine.

Note

The settings for x_trans and y_trans must match that used in fit_trajectory and appropriate inverse transformations must be set there accordingly as well.

Examples

wfit <- get_fit(cpp, y_var = "haz", method = "lwmod", deg = 2)
fit <- fit_trajectory(subset(cpp, subjid == 2), fit = wfit)
plot(fit)

auto_loess

Find best loess fit based on aic or gcv

Usage

auto_loess(data, span = c(0.01, 2), degree = c(1, 2), family = "gaussian",
  which = "gcv", ...)

Arguments

data
a data frame with columns x and y to be used in the fitting
span
a vector indicating a range (min, max) of spans to search over
degree
a vector of degrees to search over (valid values are combinations of 0, 1, 2)
family
loess family parameter
which
which method to use, “aicc” or “gcv”
additional parameters passed to loess

Summary Vis

plot_univar

Make a grid of univariate summary plots

Usage

plot_univar(dat, subject = FALSE, ncol = 3, width = 300, height = 300)

Arguments

dat
data frame
subject
should subject-level (TRUE) or time-varying (FALSE) variables be plotted?
ncol
number of columns in the grid
width
width of each plot in pixels
height
height of each plot in pixels

Details

Subject-level variables are treated differently than time-varying variables in that they are repeated for each subject. When plotting summaries of subject-level variables, the data is first subset to one record per subject.

Examples

plot_univar(cpp, subject = TRUE)
plot_univar(cpp)

plot_missing

Plot a stacked bar chart indicating NAs for each variable in a data set

Usage

plot_missing(dat, subject = FALSE, width = 800, height = 500, ...)

Arguments

dat
data frame
subject
should subject-level (TRUE) or time-varying (FALSE) variables be plotted?
width
width of plot in pixels
height
height of plot in pixels
additional parameters passed to figure

Details

Subject-level variables are treated differently than time-varying variables in that they are repeated for each subject. When plotting summaries of subject-level variables, the data is first subset to one record per subject.

Examples

plot_missing(cpp)
plot_missing(cpp, subject = TRUE)

plot_complete_pairs

Plot a heat map of frequency of “complete” (both non-NA) pairs of variables

Usage

plot_complete_pairs(dat, subject = FALSE, width = 700, height = 700,
  thresh = 0.95, ...)

Arguments

dat
data frame
subject
should subject-level (TRUE) or time-varying (FALSE) variables be plotted?
width
width of plot in pixels
height
height of plot in pixels
thresh
percentage NA threshold above which variables will be ignored (to help deal with cases involving many variables)
additional parameters passed to figure

Details

Subject-level variables are treated differently than time-varying variables in that they are repeated for each subject. When plotting summaries of subject-level variables, the data is first subset to one record per subject.

Examples

plot_complete_pairs(cpp)
plot_complete_pairs(cpp, subject = TRUE)

plot_agefreq

Plot age frequency

Usage

plot_agefreq(agefreq, xlab = "Age since birth at examination (days)",
  ylab = "# examinations", width = 700, height = 350)

Arguments

agefreq
an object returned from get_agefreq
xlab
label for x axis
ylab
label for y axis
width
width of plot in pixels
height
height of plot in pixels

Examples

agefreq <- get_agefreq(cpp)
plot_agefreq(agefreq)

plot_first_visit_age

Plot histogram and quantile plot of age at first visit

Usage

plot_first_visit_age(dat, agelab = "first visit age (days)", width = 450,
  height = 450)

Arguments

dat
a longitudinal growth study data set
agelab
label of the age axis
width
the width of each plot in pixels
height
the height of each plot in pixels

Examples

plot_first_visit_age(cpp)

plot_visit_distn

Plot histogram and quantile plot of number of “visits” for each subject

Usage

plot_visit_distn(dat, width = 450, height = 450)

Arguments

dat
a longitudinal growth study data set
width
the width of each plot in pixels
height
the height of each plot in pixels

Examples

plot_visit_distn(cpp)

Multi-Study Vis

plot_var_matrix

Plot a matrix comparing variables present in a list of studies

Usage

plot_var_matrix(dat_list, width = 845, h_padding = 0, head = NULL)

Arguments

dat_list
a list of data frames containing study data
width
width of the plot in pixels
h_padding
extra height to add to the plot to account for long variable names
head
the number of variables to limit the x-axis to (if negative, it will show all but the first head variables)

Examples

dat_list <- list(
  cpp1 = cpp[,c(1:5, 7:9, 14:19, 23:32)],
  cpp2 = cpp[,c(1:5, 11:24)],
  cpp3 = cpp
)
plot_var_matrix(dat_list)

plot_multi_subj_boxplot

Plot boxplots of distrubutions of number of records per subject for a list of studies

Usage

plot_multi_subj_boxplot(dat_list, width = 800, height = 500)

Arguments

dat_list
a list of data frames containing study data
width
width of the plot in pixels
height
height of the plot in pixels

Examples

dat_list <- list(
  cpp1 = cpp,
  cpp2 = cpp,
  cpp3 = cpp
)
plot_multi_subj_boxplot(dat_list)

plot_time_count_grid

Plot counts by age for a list of studies

Usage

plot_time_count_grid(dat_list, xlab = "Age since birth at examination (days)",
  width = 845, height = 120, y_margin = 100)

Arguments

dat_list
a list of data frames containing study data
xlab
label for x axis
width
width of the plot in pixels
height
height of each panel of the plot in pixels
y_margin
minimum padding for axis tick labels on left

Examples

dat_list <- list(
  cpp1 = cpp,
  cpp2 = cpp,
  cpp3 = cpp
)
plot_time_count_grid(dat_list)

Trelliscope Vis

trscope_trajectories

Create Trelliscope display of per-subject data and fitted trajectories

Usage

trscope_trajectories(dat, z = FALSE, center = FALSE, x_range = NULL,
  width = 500, height = 520, name = NULL, desc = "", group = NULL,
  vdbConn = getOption("vdbConn"))

Arguments

dat
either a data frame or object created by by_subject or fit_all_trajectories
z
should the trajectory fit be plotted on the z-scale?
center
should the trajectory be centered around the median WHO standard?
x_range
a vector specifying the range (min, max) that the superposed WHO growth standard should span on the x-axis
width
width of the plot
height
height of the plot
name
name of the Trelliscope display (if left NULL, will be implied by the variables being plotted and the method name)
desc
description of the Trelliscope display
group
group in which to place the Trelliscope display
vdbConn
an optional VDB connection

Examples

cppsubj <- by_subject(cpp)
cppfit  <- get_fit(cpp, method = "rlm")
cpptr   <- fit_all_trajectories(cppsubj, cppfit)
cppplot <- trscope_trajectories(cpptr)

trscope_velocities

Create Trelliscope display of the velocities of per-subject fitted trajectories

Usage

trscope_velocities(dat, z = FALSE, x_range = NULL, width = 500,
  height = 520, name = NULL, desc = "", group = NULL,
  vdbConn = getOption("vdbConn"))

Arguments

dat
either a data frame or object created by by_subject or fit_all_trajectories
z
should velocities according to z-score scale or raw scale be plotted?
x_range
a vector specifying the range (min, max) that the x-axis should span
width
width of the plot
height
height of the plot
name
name of the Trelliscope display (if NULL, will be implied by the variables being plotted and the method name)
desc
description of the Trelliscope display
group
group in which to place the Trelliscope display
vdbConn
an optional VDB connection

Examples

cppsubj <- by_subject(cpp)
cppfit  <- get_fit(cpp, method = "rlm")
cpptr   <- fit_all_trajectories(cppsubj, cppfit)
cppplot <- trscope_velocities(cpptr)

Divisions

by_subject

Divide a data set into subsets by subject

Usage

by_subject(dat)

Arguments

dat
data set to divide by subject

Examples

cppsubj <- by_subject(cpp)

by_trajectory_checkpoints

Split by-subject trajectory-fitted data by checkpoint categorizations

Usage

by_trajectory_checkpoints(dat, complete = TRUE)

Arguments

dat
a data object returned by fit_all_trajectories
complete
subset only to those that have fitted checkpoints

Examples

cppsubj <- by_subject(cpp)
cppfit  <- get_fit(cpp, method = "rlm")
cpptr   <- fit_all_trajectories(cppsubj, cppfit)
cppcp   <- by_trajectory_checkpoints(cpptr)

Data Sets

cpp

Subset of growth data from the collaborative perinatal project (CPP)

Subset of growth data from the collaborative perinatal project (CPP).

Usage

cpp

Source

https://catalog.archives.gov/id/606622

Broman, Sarah. “The collaborative perinatal project: an overview.” Handbook of longitudinal research 1 (1984): 185-227.

Examples

head(cpp)

get_smocc_data

Get SMOCC data from brokenstick, transformed to be hbgd-compatible

Usage

get_smocc_data()

who_coefs

List of WHO growth standard coefficients

A list of coefficients from the WHO for various pairs of growth standards that are used to compute quantiles and z-scores. The format is a list, where each element is a pairing of variables, e.g. “wtkg_agedays”, “htcm_agedays”, “bmi_agedays”, “hcircm_agedays”, “muaccm_agedays”, “ss_agedays”, “tsftmm_agedays”, “wtkg_lencm”“wtkg_htcm”. Within each of these elements is a list for sex with names “Female” and “Male”.

Source

0-5 years: http://www.who.int/childgrowth/software/en/

5-15 years: http://www.who.int/growthref/tools/en/

Examples

head(who_coefs$htcm_age$Female$data)

See also

who_centile2value, who_value2centile, who_zscore2value, who_value2zscore

ig_coefs

List of Intergrowth birth standard coefficients

A list of coefficients from the Integrowth birth standard.

Source

https://intergrowth21.tghn.org

References

International standards for newborn weight, length, and head circumference by gestational age and sex: the Newborn Cross-Sectional Study of the INTERGROWTH-21st Project Villar, José et al. The Lancet, Volume 384, Issue 9946, 857-868

Examples

head(ig_coefs$hcircm$Female)

See also

igb_centile2value, igb_value2centile, igb_zscore2value, igb_value2zscore

hbgd_labels

Labels for common variable names in hbgd data

Labels for common variable names in hbgd data, used in get_data_attributes if labels are not explicitly provided.

Usage

hbgd_labels

See also

get_data_attributes

hbgd_labels_df

Labels for common variable names in hbgd data

Labels for common variable names in hbgd data, used in get_data_attributes if labels are not explicitly provided.

Usage

hbgd_labels_df

Misc

get_x_range

Get the x-axis range across all subjects

Usage

get_x_range(dat, pad = 0.07)

Arguments

dat
object obtained from fit_all_trajectories
pad
padding factor - this much space as a multiple of the span of the x range will be added to the min and max

grid_deriv

Estimate derivative given a grid of points

Usage

grid_deriv(x, y)

Arguments

x
x variable (should be a regularly-spaced grid of points)
y
y variable

get_agefreq

Get age frequency

Usage

get_agefreq(dat, age_range = NULL)

Arguments

dat
a longitudinal growth study data set
age_range
optional range to ….

Examples

agefreq <- get_agefreq(cpp)
plot_agefreq(agefreq)

log10_1

log base 10 plus 1

Usage

log10_1(x)

Arguments

x
vector of data

exp10_1

Inverse of log base 10 plus 1

Usage

exp10_1(x)

Arguments

x
vector of data

get_nadir

Get nadir of a growth velocity

Usage

get_nadir(obj)

Arguments

obj
object created from fit_trajectory

Unit Conversion

cm2in

Unit conversion utility functions

Arguments

x
value(s) to convert

in2cm

Unit conversion utility functions

Arguments

x
value(s) to convert

lb2kg

Unit conversion utility functions

Arguments

x
value(s) to convert

kg2lb

Unit conversion utility functions

Arguments

x
value(s) to convert

days2years

Unit conversion utility functions

Arguments

x
value(s) to convert

years2days

Unit conversion utility functions

Arguments

x
value(s) to convert

days2months

Unit conversion utility functions

Arguments

x
value(s) to convert

months2days

Unit conversion utility functions

Arguments

x
value(s) to convert

months2years

Unit conversion utility functions

Arguments

x
value(s) to convert

years2months

Unit conversion utility functions

Arguments

x
value(s) to convert