Description Usage Arguments Details Value Author(s) References See Also Examples
This function allows for computing the weighted mean and weighted variance of a vector of continuous values.
1 | weighted.meanvar(x, w, na.rm = FALSE)
|
x |
an object containing the values whose weighted mean is to be computed. |
w |
a numerical vector of weights of the same length as |
na.rm |
|
If w
is missing then all elements of x
are given the same weight, otherwise the weights coerced to numeric by as.numeric
. On the contrary of weighted.mean the weights are NOT normalized to sum to one. If the sum of the weights is zero or infinite, NAs will be returned.
A numeric vector of two values that are the weighted mean and weighted variance respectively.
Benjamin Haibe-Kains
http://en.wikipedia.org/wiki/Weighted_variance#Weighted_sample_variance
weighted.mean
1 2 | set.seed(54321)
weighted.meanvar(x=rnorm(100) + 10, w=runif(100))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.