powered by
Compute efficiently (via Fortran code) the means, covariance and scattering matrices conditioning on a weighted or indicator matrix
covw(X, Z, normalize = TRUE)
A \((n x p)\) data matrix, with \(n\) observations on \(p\) variables.
A \((n x G)\) matrix of weights, with \(G\) number of groups.
A logical indicating if rows of Z should be normalized to sum to one.
Z
A list with the following components:
A \((p x G)\) matrix of weighted means.
A \((p x p x G)\) array of weighted covariance matrices.
A \((p x p x G)\) array of weighted scattering matrices.
# NOT RUN { # 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