Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


mclust (version 6.0.0)

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)

Value

A list with the following components:

mean

A (pxG) matrix of weighted means.

S

A (pxpxG) array of weighted covariance matrices.

W

A (pxpxG) array of weighted scattering matrices.

Arguments

X

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

Z

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

normalize

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

Author

M. Fop and L. Scrucca

Examples

Run this code
# 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))

Run the code above in your browser using DataLab