some MDS and R problems
Hi Arnaldo, You ask several disjointed question that I don't really follow (esp your last point about unique), but in response to:
When I delete a sample I do not loose some weight?
No, nMDS only cares about trying to position points in a k dimensional space such that the distance between points in this k dimensional space best represents the rank ordering of the original dissimilarities. If two samples have 0 dissimilarity, they should occupy the same location on the plot (in the k dimensional space); one does not influence the other. Hence simply deleting one of the pair of samples that have zero distance to one another is appropriate. As for the code I wrote in the email you cite: minDij <- min(Dij[Dij > 0]) / 2 Dij[Dij <= 0] <- minDij We assume Dij is the object containing your distance matrix. In your example code, it would be Dij <- as.matrix(dissim1) for example. The first line of my code calculates half the smallest observed dissimilarity. If we break it down, the code in that first line does the following [there was a missing `]` in the version you quote and probably in my original]: Dij[Dij > 0] subsets Dij so that we only work with the dissimilarities that are positive. This way of indexing the matrix Dij results in a vector of positive dissimilarities. We then apply the min( ) function to this vector of positive dissimilarities to return the smallest positive dissimilarity observed. We then halve this minimum value and store it in the object minDij. The second line of my code uses this dissimilarity value (minDij) to replace the observed dissimilarities in Dij that are less than or equal to 0. Hope this is of use. If you still can't get this to work, post back and let us know. All the best, G
On Tue, 2010-06-15 at 08:34 -0300, Arnaldo Russo wrote:
Hi all, I'm executing some multivariate exploratory annalysis, with vegan and MASS packages. Some problems are not solved for me at this moment. I have read all past discussions over MDS problems. In my studies occurs a situation that some samples are equal each other, and this results in zero dissimilarities. I tryed with no success, use the stepacross function. So, in this case I changed one of these zero dissimilarities values for a minimum (1e-5). Some of these modifications are different than "stepacross" or same isoMDS(x.dist + 1e-5) (proposed by Jari oksanen to 'lie' to isoMDS? When I delete a sample I do not loose some weight? Changing one of those zero dissimilarities and using zerodist = "add" option of metaMDS, it passed the current error (zero or negative distance between objects). Someone could explain the function posted by Gavin Simpson (Jan 12, 2010; 05:45pm Re: Non-metric multidimensional scaling (NMDS) help). I didn't get some result. If there is a good reason, and you want to include all samples, then
you'll need to come up with a means for handling them. metaMDSdist allow
you to add a small value to the zero dissimilarities. The details are in
the code, but effectively all zero distances are replaced by half the smallest non zero distance. You could do a similar replacement yourself if you feel this is warranted and/or justified. minDij <- min(Dij[Dij > 0) / 2 Dij[Dij <= 0] <- minDij Will do this replacement if Dij is your matrix (replace Dij with whatever the name of your matrix is). Then supply the new matrix to metaMDS. "
When I use unique function as #x.dist <- dist(unique(X))
this cutted some of my samples that I do not know. I can't see my variables
in the plot. Some help?
Cheers, Arnaldo.
epi<- read.table("epi.txt", h=TRUE,row.names=1)
library('vegan')
library('MASS')
epi.<- as.matrix(epi)
dissim1<- vegdist(epi., method="jaccard", binary=TRUE)
dissim1.mds<-metaMDS(dissim1,k=2)
plot(dissim1.mds,type="n")
text(dissim1.mds, labels=as.character(row.names(epi)))
#epi
sample sp1 sp2 sp3 sp4 sp5 sp6 sp7 sp8 sp9
sp10 sp11 sp12 sp13 sp14 sp15 sp16 sp17 sp18 sp19
1E 1 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
2E 0 0 1 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
3E 1 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
4E 1 0 1 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
5E 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
6E 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
7M 1 0 1 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0
8E 1 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0
11E 1 0 0 0 1 0 1 0 0 0 0 0 0 0
0 0 0 0 0
12E 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0
13E 0 0 0 0 0 0 1 0 0 0 1 1 0 0
0 0 0 0 0
14E 0 0 1 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0
15E 1 0 0 0 0 0 1 0 0 0 0 0 1 0
0 0 0 0 0
17E 0 0 0 0 1 0 1 0 1 0 0 0 0 0
0 0 0 0 0
18E 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0
20E 1 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
21E 1 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0
22E 1 0 0 0 1 0 0 0 1 0 0 0 0 0
0 0 0 0 0
23E 1 0 1 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
27E 1 0 0 1 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
28E 1 0 0 0 1 0 1 1 0 0 1 0 0 0
0 0 0 0 0
30E 1 1 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0
31E 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0
32E 1 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0
9E 0 0 0 0 0 1 1 1 1 1 0 0 0 0
0 0 1 0 0
10E 0 0 1 0 0 1 1 0 1 1 1 0 0 0
0 1 0 1 1
------
Arnaldo D`Amaral Pereira Granja Russo
Instituto Ambiental Boto Flipper
www.institutobotoflipper.com.br
[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%