weighted.var: Compute Weight Variance

weighted.varR Documentation

Compute Weight Variance

Description

Compute Weight Variance

Usage

weighted.var(
  x,
  weights = NULL,
  normwt = FALSE,
  na.rm = TRUE,
  method = c("unbiased", "ML")
)

Arguments

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.

Examples

set.seed(1)
x <- runif(500)
wts <- sample(1:6, 500, TRUE)
weighted.var(x,wts)

cardiomoon/webrPSM documentation built on Feb. 2, 2024, 3:55 a.m.