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 Rui Barradas <ruipbarra...@sapo.pt>

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:

I have a matrix d representing distances.
I need to find B=X'X
X=matrix that generated these distances.+

B[i,j]=-(1/2)*{[d[i,j]^2-[(1/**n)*sum for i=1...n(d[i,j])^2]-[(1/n)sum
for
j=1...n(d[i,j])^2]+[(1/n^2)sum for i=1...n sum for j=1...n (d[i,j])^2]}

it's right if i do
B=matrix(,nrow=dim(d)[1],ncol=**dim(d)[2])
for (i in 1:dim(d)[1])
for (j in 1:dim(d)[2]){
B=(-(1/2))*(d[i,j]^2-d[i,]^2-**d[,j]^2+d[,]^2)
}
or i have to put
B[i,j]=(-(1/2))*(d[i,j]^2-d[i,**]^2-d[,j]^2+d[,]^2)
??

         [[alternative HTML version deleted]]

______________________________**________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide http://www.R-project.org/**
posting-guide.html <http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.




______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to