weighted.median {gamboostLSS} | R Documentation |
Weighted Median
Description
Function to compute the weighted median.
Usage
weighted.median(x, w = 1, na.rm = FALSE)
Arguments
x |
a numeric vector containing the values whose median is to be computed. |
w |
weights that are used to compute the median. This can be either a
single value (which will be used as weight for all observations)
or a numeric vector of the same length as |
na.rm |
logical. Should |
Details
The weighted median is computed as the value where the cumulative relative weights (relative to the sum of all weights) crosses 0.5.
This function is used in the stabilization of the negative gradient via the meadian absolute deviation (MAD). For details see Hofner et al (2015).
References
B. Hofner, A. Mayr, M. Schmid (2016). gamboostLSS: An R Package for Model Building and Variable Selection in the GAMLSS Framework. Journal of Statistical Software, 74(1), 1-31.
Available as vignette("gamboostLSS_Tutorial")
.
See Also
glmboostLSS
, gamboostLSS
and
blackboostLSS
for fitting of GAMLSS where the
standardization is explained in more detail.
Examples
## compute the weighted median with case weights
x <- c(1, 2, 3, 4)
w <- c(0, 1, 2, 3)
weighted.median(x, w)
## compute the weighted median with arbitrary weights
x <- rnorm(100)
w <- runif(100)
weighted.median(x, w)