weighted.var | R Documentation |
Compute Weight Variance
weighted.var(
x,
weights = NULL,
normwt = FALSE,
na.rm = TRUE,
method = c("unbiased", "ML")
)
x |
A numeric vector |
weights |
a numeric vector of weights |
normwt |
logical specify normwt=TRUE to make weights sum to length(x) after deletion of NAs. If weights are frequency weights, then normwt should be FALSE, and if weights are normalization (aka reliability) weights, then normwt should be TRUE. In the case of the former, no check is made that weights are valid frequencies. |
na.rm |
logical set to FALSE to suppress checking for NAs |
method |
determines the estimator type; if 'unbiased' (the default) then the usual unbiased estimate (using Bessel's correction) is returned, if 'ML' then it is the maximum likelihood estimate for a Gaussian distribution. In the case of the latter, the normwt argument has no effect. Uses stats:cov.wt for both methods. |
set.seed(1)
x <- runif(500)
wts <- sample(1:6, 500, TRUE)
weighted.var(x,wts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.