Determines the reference name for each measurement based on age, sex, outcome and gestational age.

set_refcodes(data)

Arguments

data

Data frame in the long form, where each measurement has its own row. Required variables are xname, yname, x and sex. Optional variables are age and ga.

Value

A character vector of nrow(data) elements.

Details

The present implementation uses three Dutch references: a term reference, a pre-term reference for children born ga <= 36 aged 0 - 4 years, and a reference for the D-score. For head circumference, pre-term references up to 1.5 years are used, and term references thereafter. Together, this specification defines the analysis metric in JAMES.

The pre-term references govern gestational ages between 25 and 36 weeks. The function scores pre-term born infants with gestational ages between 21 and 24 weeks relative to the 25-week references.

If the variable ga is not present in data, the function assumes term births for all children and prints a message.

References for the Development Score (D-score) for pre-term were created by shifting the term reference by 40 - ga weeks to the right, so the references start at a later calender age. Because pre-terms are older their Z-score initially score higher than those of terms. The effect disappears after four months.

The yname field currently supports the following measurements: hgt (length/height in cm), wgt (body weight in kg), hdc (head circumference in cm), bmi (body mass index in kg/m**2), wfh (weight for height in kg) and dsc (D-score).

The xname field currently supports the following measurements: age (child age, decimal years) and hgt (height in cm, only for wfh).

Author

Stef van Buuren 2021

Examples

df <- data.frame(
  xname = c("age", "age", "age", "age", "hgt", "age", "age"),
  yname = c("hgt", "hgt", "hdc", "hdc", "wfh", "dsc", "wgt"),
  x = c(0.1, NA, 0.1, 1.6, 60, 1.0, 1.0),
  sex = c(rep(c("male", "female"), 3), "male"),
  ga = c(39, 27, 27, 27, 39, 40, 40))
refcodes <- set_refcodes(df)

# show the preterm 27 weeks hgt reference
centile::load_reference(refcodes[2], pkg = "nlreferences")
#> # A tibble: 69 × 4
#>         x     L     M      S
#>     <dbl> <dbl> <dbl>  <dbl>
#>  1 0          1  50.9 0.0376
#>  2 0.0192     1  51.6 0.0375
#>  3 0.0383     1  52.3 0.0375
#>  4 0.0575     1  52.9 0.0374
#>  5 0.0767     1  53.6 0.0373
#>  6 0.0958     1  54.3 0.037 
#>  7 0.115      1  55.0 0.0369
#>  8 0.134      1  55.7 0.0368
#>  9 0.153      1  56.4 0.0368
#> 10 0.172      1  57.0 0.0367
#> # ℹ 59 more rows