matW {rchemo}R Documentation

Between and within covariance matrices

Description

Calculation of within (matW) and between (matB) covariance matrices for classes of observations.

Usage


matW(X, y)

matB(X, y)

Arguments

X

Data (n, p) on whch are calculated the covariances.

y

Class membership (n, 1).

Details

The denominator in the variance calculations is n.

Value

For (matW):

W

within covariance matrix.

Wi

list of covariance matrices for each class.

lev

classes

ni

number of observations in each per class

For (matB):

B

between covariance matrix.

ct

matrix of class centers.

lev

classes

ni

number of observations in each per class

Examples


n <- 8 ; p <- 3
X <- matrix(rnorm(n * p), ncol = p)
y <- sample(1:2, size = n, replace = TRUE)
X
y

matW(X, y)

matB(X, y)

matW(X, y)$W + matB(X, y)$B
(n - 1) / n * cov(X)


[Package rchemo version 0.1-2 Index]