colWeightedSds {DelayedMatrixStats} | R Documentation |
Computes a weighted variance / standard deviation of a numeric vector or across rows or columns of a matrix.
colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ...) colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ...) rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ...) rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, ...) ## S4 method for signature 'DelayedMatrix' colWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ...) ## S4 method for signature 'DelayedMatrix' colWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ...) ## S4 method for signature 'DelayedMatrix' rowWeightedSds(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ...) ## S4 method for signature 'DelayedMatrix' rowWeightedVars(x, w = NULL, rows = NULL, cols = NULL, na.rm = FALSE, force_block_processing = FALSE, ...)
x |
A NxK DelayedMatrix. |
w |
a vector of weights the same length as |
rows |
A |
cols |
A |
na.rm |
a logical value indicating whether |
... |
Additional arguments passed to specific methods. |
force_block_processing |
|
The estimator used here is the same as the one used by the "unbiased"
estimator of the Hmisc package. More specifically,
weightedVar(x, w = w) == Hmisc::wtd.var(x, weights = w)
,
Returns a numeric
scalar.
Missing values are dropped at the very beginning,
if argument na.rm
is TRUE
, otherwise not.
For the non-weighted variance, see var
.
# A DelayedMatrix with a 'SolidRleArraySeed' seed dm_Rle <- RleArray(Rle(c(rep(1L, 5), as.integer((0:4) ^ 2), seq(-5L, -1L, 1L))), dim = c(5, 3)) colWeightedSds(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to rowwise means colWeightedVars(dm_Rle, w = 1 / rowMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedSds(dm_Rle, w = 1 / colMeans2(dm_Rle)) # Specifying weights inversely proportional to columnwise means rowWeightedVars(dm_Rle, w = 1 / colMeans2(dm_Rle))