weightedVar: Weighted variance

Description Usage Arguments Value Missing values Author(s) See Also

Description

Computes a weighted variance of a numeric vector.

Usage

1
2
## Default S3 method:
weightedVar(x, w, na.rm=FALSE, center=NULL, ...)

Arguments

x

a numeric vector containing the values whose weighted variance is to be computed.

w

a vector of weights the same length as 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.

na.rm

a logical value indicating whether NA values in x should be stripped before the computation proceeds, or not. If NA, no check at all for NAs is done. Default value is NA (for effiency).

center

Optional numeric scalar specifying the center location of the data. If NULL, it is estimated from data.

...

Not used.

Value

Returns a numeric scalar.

Missing values

Missing values are dropped at the very beginning, if argument na.rm is TRUE, otherwise not.

Author(s)

Henrik Bengtsson

See Also

For the non-weighted variance, see var.


matrixStats documentation built on May 2, 2019, 4:52 p.m.