For the matrix x, we compute the MLE for the population covariance matrix under the assumption that the data are sampled from \(K\) multivariate normal populations having equal covariance matrices.

cov_pool(x, y)

Arguments

x

data matrix with n observations and p feature vectors

y

class labels for observations (rows) in x

Value

pooled sample covariance matrix of size \(p \times p\)

Examples

cov_pool(iris[, -5], iris$Species)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width #> Sepal.Length 0.25970800 0.09086667 0.16416400 0.03763333 #> Sepal.Width 0.09086667 0.11308000 0.05413867 0.03205600 #> Petal.Length 0.16416400 0.05413867 0.18148400 0.04181200 #> Petal.Width 0.03763333 0.03205600 0.04181200 0.04104400