Re: [R] centering matrix

2013-01-29 Thread Rui Barradas
Hello, Please keep the discussion on the R-Help list, there's no reason not to. As for your question, can you be more specific? Also, take a look at function ?scale. Rui Barradas Em 29-01-2013 23:31, Eleonora Schiano escreveu: i have to do multidimensional scaling. Can you help me? 2013/1/29

Re: [R] centering matrix

2013-01-29 Thread Rui Barradas
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-