Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

covw

Weighted means, covariance and scattering matrices conditioning on a weighted matrix


Description

Compute efficiently (via Fortran code) the means, covariance and scattering matrices conditioning on a weighted or indicator matrix

Usage

covw(X, Z, normalize = TRUE)

Arguments

X

A (n x p) data matrix, with n observations on p variables.

Z

A (n x G) matrix of weights, with G number of groups.

normalize

A logical indicating if rows of Z should be normalized to sum to one.

Value

A list with the following components:

mean

A (p x G) matrix of weighted means.

S

A (p x p x G) array of weighted covariance matrices.

W

A (p x p x G) array of weighted scattering matrices.

Author(s)

M. Fop and L. Scrucca

Examples

# Z as an indicator matrix
X <- iris[,1:4]
Z <- unmap(iris$Species)
str(covw(X, Z))
# Z as a matrix of weights
mod <- Mclust(X, G = 3, modelNames = "VVV")
str(covw(X, mod$z))

mclust

Gaussian Mixture Modelling for Model-Based Clustering, Classification, and Density Estimation

v5.4.10
GPL (>= 2)
Authors
Chris Fraley [aut], Adrian E. Raftery [aut] (<https://orcid.org/0000-0002-6589-301X>), Luca Scrucca [aut, cre] (<https://orcid.org/0000-0003-3826-0484>), Thomas Brendan Murphy [ctb] (<https://orcid.org/0000-0002-5668-7046>), Michael Fop [ctb] (<https://orcid.org/0000-0003-3936-2757>)
Initial release
2022-05-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.