Skip to contents

Calculates the SDS for a pubertal stage measurement, given the patient's age and observed stage, by interpolating between the surrounding reference percentiles.

Usage

calculate_sds(age, stage, type, ref = tanner::nl1997)

Arguments

age

Vector of patient ages. The length of age determines the length of the return value (see Value below).

stage

Vector of patient stages, the same length as age (one stage per age; not recycled). For type = "tv" this is the raw testicular volume in **ml**, as read off a Prader orchidometer or otherwise measured; it need not be one of the 12 Prader bead volumes (1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 20, 25) — any intermediate value (e.g. 11 or 16 ml) is bracketed between the surrounding reference percentiles. For all other types, stage is the integer Tanner stage (1-5 for "gen", "phb", "bre", "phg"; 1-2 for "men"). A stage shorter or longer than age is not supported: it is silently truncated or padded rather than recycled (e.g. a length-1 stage does not apply to every element of age) and can also produce NAs, a warning, or a "subscript out of bounds" error depending on type – do not rely on any of these behaviors, always pass stage the same length as age.

type

Reference type: one of "gen", "phb", "tv", "bre", "phg" or "men".

ref

Reference data, as produced by nl1997.

Value

A numeric vector of SDS values, the same length as age (one value per element of age).

Details

Implements the mid-P value method of van Buuren & Ooms (2009), equation (6): treating the observed stage c as a coarsened version of a continuous latent variable, uniformly distributed within the stage's probability interval [P(Y<c|X), P(Y<c+1|X)). The mid-P value pi_c = P(Y<c|X) + P(Y=c|X)/2 is the mean of that latent variable, and Z = qnorm(1 - pi_c) = qnorm(1 - (P(Y>=c|X) + P(Y>=c+1|X))/2) converts it to a Z-score/SDS. This is why the SDS averages the surrounding-stage percentiles rather than looking up a single stage's percentile directly: the averaging is the mid-P value itself, not an ad hoc smoothing step. The same formula applies to tv's 12 Prader bead categories, treating each raw ml reading as belonging to the bead-category interval it falls into (see below).

References

van Buuren S, Ooms JCL (2009). Stage line diagram: An age-conditional reference diagram for tracking development. Statistics in Medicine, 28(11), 1569-1579. doi:10.1002/sim.3567

Examples

# a single boy, genital stage 3 at age 12
calculate_sds(age = 12, stage = 3, type = "gen")
#> [1] 1.11302

# a boy's genital-stage trajectory over three visits
calculate_sds(age = c(10, 12, 14), stage = c(1, 3, 4), type = "gen")
#> [1] -0.3655512  1.1130196  0.3941098

# testicular volume in ml, interpolated between Prader beads
calculate_sds(age = 13, stage = 11, type = "tv")
#> [1] 0.4806011