View source: R/curve_interpolation.R
curve_interpolation | R Documentation |
By convention, we connect the points of a growth curve by straight lines. This is OK when ages are relatively close together. However, for ages that are more apart, the straight line gives an ugly representation that doesn't follow the real growth during the interval.
curve_interpolation(
data,
xname = "x",
yname = "y",
xout = numeric(0),
refcode = NULL,
rule = 2L
)
data |
A data frame in long format, with columns for person
number (named |
xname |
Name of the variable on the horizontal axis. |
yname |
Name of the variable on the vertical axis. |
xout |
A vector of values for the horizontal axis in the scale
of the variable |
refcode |
The name of reference needed to calculate the Z-score scores and the back-transformation to measured scores. There can only be one reference. |
rule |
The |
The curve_interpolation()
function provides a solution
for this. It defines a number of additional points (specified
through the xout
argument), and calculates the linear
interpolation between these points in the Z-scores metric. After
that, the procedure transforms back the interpolated Z-scores
to the original scale, so the curve points follow the curvy
centiles.
A tibble
with five columns: id
, xname, yname,
zname and obs
. The obs
variables signals whether
the point is observed or not.
Stef van Buuren, 2021
centile::y2z()
, centile::z2y()
data <- data.frame(
id = c(1, 1, 1, 2, 3, 3, 3),
age = c(0, 0.2, 1.2, 0.5, 0.1, 1, 1.3),
hgt = c(52, 60, 78, 69, 62, 78, 82)
)
refcode <- "nl_1997_hgt_male_nl"
xout <- seq(0, 3, 0.2)
int <- chartplotter:::curve_interpolation(data,
xname = "age", yname = "hgt",
xout = xout, refcode = refcode
)
int
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.