[R] NMDS in Vegan: problems in stressplot, best solution

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Apr 26 21:25:45 CEST 2013


On Fri, 2013-04-26 at 12:42 -0500, Kumar Mainali wrote:
> Hello,
> 
> I can draw a basic stress plot for NMDS with the following code in package
> Vegan.
> > stressplot(parth.mds, parth.dis)
> 
> When I try to specify the line and point types, it gives me error message.
> > stressplot(parth.mds, parth.dis, pch=1, p.col="gray", lwd=2, l.col="red")
> Error in plot.xy(xy, type, ...) : invalid plot type
> 
> In the above code, if I removed line type, it does give me the plot only of
> points with my choice of type.
> > stressplot(parth.mds, parth.dis, pch=1, p.col="gray")
> 
> Why cannot I define both line and point at the same time?

You can. What you can't do is use argument `dis` with an metaMDS object.
If you use:

stressplot(parth.mds, pch=1, p.col="gray", lwd=2, l.col="red")

you'll see it works just fine.

We'll see about providing a better error message if you do what the
documentation asks you not to.

> If I have 100 iterations for metaMDS, then when I plot the result, does it
> give me result from best solution?

The best solution it encountered in the 100 random starts, yes.

> How do I know that.

It is implied in point 4. of the Details section of ?metaMDS.

>  Can you plot the
> Stress by Iteration number?

Not in a graphical plot. The stresses for each iteration are printed to
the console at each iteration. Note these "iterations" are random
starts, each of which has iterations of the algorithm.

HTH

G

> parth.mds <- metaMDS(WorldPRSenv, distance = "bray", k = 2, trymax = 100,
> engine = c("monoMDS", "isoMDS"),
>  autotransform =TRUE, wascores = TRUE, expand = TRUE, trace = 2)
> plot(parth.mds, type = "p")
> 
> Thanks in advance,
> Kumar
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list