Calculates the z or z(log) values for laboratory measurement standardisation
as proposed in Hoffmann 2017 et al. for a complete data.frame
.
data.frame
, with the columns: "age", numeric
, "sex", factor
and more user defined numeric
columns that should be z/z(log) transformed.
data.frame
, reference table, has to have the columns:
"age", numeric
(same units as in age
, e.g. days or years, age of 0
matches all ages),
"sex", factor
(same levels for male and female as sex
and a special level
"both"
), "param", character
with the laboratory parameter name that have
to match the column name in x
, "lower" and "upper", numeric
for the
lower and upper reference limits.
numeric
, probabilities of the lower and upper reference limit,
default: c(0.025, 0.975)
(spanning 95 %). Has to be of length 2 for
numeric
or a two-column matrix
with as many rows as elements in x
.
logical
, should z (log = FALSE
, default) or
z(log) (log = TRUE
) calculated?
data.frame
, with the columns: "age", "sex" and all numeric
columns z/zlog transformed. If a column name is missing in limits$param
a warning is thrown and the column is set to NA
.
This is a wrapper function for z()
and lookup_limits()
. Please find
the details for the z/z(log) calculation at z()
.
zlog_df
is an alias for z_df(..., log = TRUE)
.
Georg Hoffmann, Frank Klawonn, Ralf Lichtinghagen, and Matthias Orth. 2017. "The Zlog-Value as Basis for the Standardization of Laboratory Results." LaboratoriumsMedizin 41 (1): 23–32. doi:10.1515/labmed-2016-0087 .
l <- data.frame(
param = c("alb", "bili"),
age = c(0, 0),
sex = c("both", "both"),
units = c("mg/l", "µmol/l"),
lower = c(35, 2),
upper = c(52, 21)
)
x <- data.frame(
age = 40:48,
sex = rep(c("female", "male"), c(5, 4)),
# from Hoffmann et al. 2017
alb = c(42, 34, 38, 43, 50, 42, 27, 31, 24),
bili = c(11, 9, 2, 5, 22, 42, 37, 200, 20)
)
z_df(x, l)
#> age sex alb bili
#> 1 40 female -0.345876 -0.103156
#> 2 41 female -2.190548 -0.515780
#> 3 42 female -1.268212 -1.959964
#> 4 43 female -0.115292 -1.341028
#> 5 44 female 1.498796 2.166276
#> 6 45 male -0.345876 6.292516
#> 7 46 male -3.804636 5.260956
#> 8 47 male -2.882300 38.889812
#> 9 48 male -4.496388 1.753652
zlog_df(x, l)
#> age sex alb bili
#> 1 40 female -0.15472223 0.8819855
#> 2 41 female -2.24698167 0.5474516
#> 3 42 female -1.14569028 -1.9599640
#> 4 43 female 0.07826303 -0.4324351
#> 5 44 female 1.57162335 2.0375165
#> 6 45 male -0.15472223 3.1154950
#> 7 46 male -4.52949253 2.9041899
#> 8 47 male -3.16160843 5.7172179
#> 9 48 male -5.69571148 1.8786269