weightedVar(x, w=NULL, idxs=NULL, na.rm=FALSE, center=NULL, ...)
colWeightedVars(x, w=NULL, rows=NULL, cols=NULL, na.rm=FALSE, ...)
rowWeightedVars(x, w=NULL, rows=NULL, cols=NULL, na.rm=FALSE, ...) weightedSd(...)
colWeightedSds(x, w=NULL, rows=NULL, cols=NULL, na.rm=FALSE, ...)
rowWeightedSds(x, w=NULL, rows=NULL, cols=NULL, na.rm=FALSE, ...)
x
giving the weights
to use for each element of x
. Negative weights are treated
as zero weights. Default value is equal weight to all values.numeric
scalar.na.rm
is TRUE
, otherwise not.weightedVar(c(2,4,5), w=c(2,1,3)) == var(c(2, 2, 4, 5, 5, 5))
.
Note that this means that the estimate is not invariant
to a scale factor on the weights, e.g. passing normalized weights
will not give the same estimate as non-normalized weights.var
.