Skip to contents

wcov computes the estimates of the weighted covariance matrix and the weighted mean of the data.

Usage

.wcov(x, w)

Arguments

x

A matrix with \(m\) columns and \(n\) rows, where each column represents a different variable and each row a different observation.

w

A non-negative and non-zero vector of weights for each observation. Its length must equal the number of rows of x.

Value

A list with two components:

  • center: an estimate for the center (mean) of the data.

  • cov: the estimated (weighted) covariance matrix.

Author

Simon Garnier, garnier@njit.edu

Examples

m <- matrix(c(rnorm(500, 6), rnorm(500, 11, 3)), ncol = 2)
w <- runif(500)
boRing:::.wcov(m, w)
#> $center
#> [1]  6.032538 10.918163
#> 
#> $cov
#>            [,1]       [,2]
#> [1,]  1.0001911 -0.1396961
#> [2,] -0.1396961  8.9154637
#>