A function which performs row-, column-, double- or overall-centering of a matrix
centering(Mat, rowcenter = FALSE, colcenter = FALSE, grandcenter = FALSE)
Mat | A numerical matrix. |
---|---|
rowcenter | Logical. If |
colcenter | Logical. If |
grandcenter | Logical. If |
A centered matrix
If both row- and colcenter are TRUE
the matrix is double centered.
This is done by first subtracting the pre-computed row-means, then the
pre-computed column means and finally, the grand mean is added back in.
data(BCdata) Xc <- centering(BCdata$X, FALSE, TRUE, FALSE)