Skip to content
Prev 316403 / 398503 Next

centering matrix

Hello,

The question is a bit confusing.
If you nedd to compute B = X'X, all you have to do is

B <- t(X) %*% X

If you want to compute the other formula, the following avoids loops.

n <- nrow(d)
B <- -d^2/2 - rowSums(d^2)/n - colSums(d^2)/n + sum(d^2)/n^2


Hope this helps,

Rui Barradas

Em 28-01-2013 22:35, Eleonora Schiano escreveu: