[R] Adonis and nmds help and questions for a novice.

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Oct 4 22:36:25 CEST 2011


On Tue, 2011-10-04 at 08:45 +0000, Ashley Houlden wrote:
> Hi,
> 
> forgive me if someone has already posted about this but I have had a
> look and cannot find the answer, also I am very new to R and been
> getting the grips with this.
> 
> I have been trying to use Adonis to find out if there are significant
> difference between groups on data that I have analyses with NMDS, and
> have been struggling with getting this to work and understanding what
> is going on.  I am looking at diversity in different soils with either
> woodland or grassland habitats.
> 
> I have run the scripts
> 
> library(vegan)
> library(ecodist)
> library(MASS)
> mydata <- read.table("ash_data.csv", header=TRUE, sep=",",
> row.names="Site")
> 
> envdata_fit <- read.table("ash_env.csv", header=TRUE, sep=",",
> row.names="Site")
> 
> #distance matrix of samples using bray curtis
> d= bcdist(mydata, rmzero=FALSE)
> 
> And then using the distance matrix from this to use for adoins? Is
> this correct.
> 
> With this I have then run Adonis
> 
> results = adonis(d ~ wood, envdata_fit, permutations = 1000)
> 
> and get significant values to see if sig diff in diversity between
> wood and grass habitat.
> 
> However I have been reading about combining the variables, but there
> seems to be different ways for example
> 
> results = adonis(d ~ wood+soil, envdata_fit, permutations = 1000)
> 
> so get sig values for Wood and soil
> 
> or
> 
> results = adonis(d ~ wood*soil, envdata_fit, permutations = 1000)
> 
> And I get sig values for wood, soil, and wood soil interaction.
> 
> This seems to make sense, however for both if I put the variable the
> other way around (soil+wood or soil*wood) I get very different sig
> values, even accounting for the fact they vary slightly due to the
> permutations. So whats is going on and why to the the values change so
> much?

You can isolate the effects due to different permutations being used by
setting a seed via set.seed().

As ?adonis says, sequential sums of squares are used. If there is
imbalance in your design it isn't surprising that the results are not
invariant to the ordering of terms in the formula.

> I was also wondering in Adonis, can you nest treatments, so see effect
> of soil removing the effect of woodland as you can with anova?

Not 100% sure what you mean by nested, but adonis() uses the full
functionality of R's formula interface. See The R manual for details
or ?formula. ?adonis also has details of how you might test a nested
design in the Details section - this might not be what you want but it
does allow you to test for an effect of one variable by conditioning the
permutations on another.

> Another general questions as well, if I have more than two groups in a
> treatment, say for soil, clay, sand, loam and do the stats, and I get
> a significant value, what does it actually mean, is it that soil
> generally has an effect, with each group separate, or there are
> general differences between soils which may be one group is very
> different to the other two?

The permutation test, test at the level of the factor, not pairwise
comparisons of the levels within the factor. So you get information on
Soil, not on Clay, Sand, Loam levels. This is the same as you would get
if you did anova(mod) where mod was a linear model with a factor
predictor.

betadisper() the sister function to adonis() which tests for differences
of multivariate dispersions, not differences of multivariate means, does
allow the sorts of pairwise tests you are thinking of, but we haven't
implemented this in adonis yet I'm afraid.

HTH

G

> Many many thanks to anyone who can help me as I have asked people who
> use R near me and no-one is sure and uses Adonis..
> 
> Ash

> ______________________________________________
> R-help at 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.

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