| Author |
Comment/Response |
Robert Sterling
|
10/05/98 11:13pm
I am trying to run a Principal Components analysis using a minimal spanning tree. What I begin with is a system of linear algebra and data which I am sure works, because I have used it before; but now I am trying to recreate an old project with the data and it is not working.
I get the following error after my second input, ''Inner::heads:Heads Transpose and TakeColumns at positions 3 and 2 are expected to be the same''.
The error has sense to it but I still do not completely understand what is my mistake.
Any help on this one?
Robert
In[1]:=
Needs[''Graphics`Master`''];
Needs[''LinearAlgebra`MatrixManipulation`''];
m=ReadList[''data.txt'',Number,RecordLists->True];
labels=ReadList[''oecd.txt'',Word,RecordLists->True];
h[d_]:=Plus[Times[-1,Apply[Plus,m]/Length[m]],d];
x=Map[h,m];
s=(Transpose[x].x)/Length[m];
diagonal[matrix_List]:=Transpose[matrix,{1,1}];
d=DiagonalMatrix[1/Sqrt[diagonal[s]]];
r=N[Transpose[d].s.d];
eigvals=Eigenvalues[r];
eigvecs=Eigenvectors[r];
straw=x.d;
pc=straw.Transpose[eigvecs];
points=TakeColumns[full,{1,3}];
In[2]:=
m//TableForm
raw//TableForm
eigvals//TableForm
TakeColumns[eigvecs,{1,3}]//TableForm
TakeColumns[pc,{1,3}]//TableForm
In[3]:=
fd[x_,y_]:=(x-y)^2;
gd[c_,d_,e_]:=(Apply[plus,List[c,d,e]])^.5;
Euc[m_]:=Inner[fd,m,Transpose[m],gd];
mm=Euc[points];
''Inner::heads:Heads Transpose and TakeColumns at positions 3 and 2 are expected to be the same.''
URL: , |
|