JSlocombe95 JSlocombe95 - 3 months ago 27
R Question

How can I compare two co variance matrices in R?

I need to test the equality of two co variance matrices for my two subsets:
trains[1:5, c(3,6,8,11)] and trains[6:10, c(3,6,8,11)].
Should I be using a boxM test or something similar? Thanks


You can use compareCov from the package covmat.

As an example I will use the longely dataset from the stats package:


(Cl <- cor(longley))
compareCov(Cl, Cl, labels = c("Robust Croux", "Robust"))

enter image description here

You can find more examples and details in the package's Vignette.


If you're asking how to select the most appropriate statistical test, then that's more of a question for Cross Validated, like Ben Bolker just commented.