[R-sig-eco] adonis and contrasts

Jari Oksanen jari.oksanen at oulu.fi
Mon Apr 26 18:08:14 CEST 2010


On 26/04/10 18:08 PM, "Christine Griffiths"
<Christine.Griffiths at bristol.ac.uk> wrote:

> Dear Jari,
> 
> Thank you very much for your help. I have tried both methods, but neither
> of which seem to have worked. This is most likely an oversight on my part
> so I have included an example of the alternative method provided with the
> hope that I am simply missing something.
> 
> dataset[1:5,]
>   ID  Area Treatment Block BlockID Month X5 X6 X7 X8 X9 X11 X12 X13 X14 X15
> 1  1 lower 1.Control     a       1    1a 11  2  1  0 58  10  28 137   0   0
> 
> 2  2 lower 1.Control     b       2    1a  6 10  2  0 36   1  26 192  65   0
> 
> 3  3 lower 1.Control     c       3    1a  2  0  0  0 27  41  33 394  16   0
> 
> 4  4 upper 1.Control     d       4    1a 22 54  7  0 26  42  10 275 137   4
> 5  5 upper 1.Control     e       5    1a  1  5 10  0  0  19  45 599  60   0
> 
> 
> X16 X17 X18 X19 X20 X22 X23 X24 X25 X26 X27 X28 X29 X30
> 87  18  68  10   0   0  43   0 0   0   0   0   0   5
> 6  35  94  14   0   4  28   2  0   0   0   0   6   8
> 3  14   4  16   0   2  61   1  0   0   0   0   1  11
> 22  10  30   1   0  35  19   0  1   3   2   0   0   0
> 6   3   0   5   0   4  39   0  0   0   0   0   0   6
> 
> dat<-dataset[1:16,7:30]
> datenv<-dataset[1:16,1:6]
> 
> treatment<-as.factor(Treatment)
> levels(treatment)
> contrasts(treatment)<-cbind(c(-2,1,1),c(0,-1,1))
> contrasts(treatment)
> treatment<-model.matrix(~treatment)[,-1]
> 
> m1<-adonis(dat~treatment,data=datenv,strata=datenv[,"Block"],permutation=999,m
> ethod="bray")
> 
> m1
> 
> Call:
> adonis(formula = dat ~ treatment, data = datenv, permutations = 999,
> method = "bray", strata = datenv[, "Block"])
> 
>                  Df SumsOfSqs   MeanSqs   F.Model     R2 Pr(>F)
> treatment  2.000000  0.112451  0.056225  0.680226 0.0947   0.48
> Residuals 13.000000  1.074541  0.082657           0.9053
> Total     15.000000  1.186991                     1.0000
> 
> The above result does not seem to account for the contrast. Am I missing
> something?

Christine,

The above result should *not* account for the contrasts. This is the total
effect of your variables (treatment), and the result here should be
independent of the applied contrasts (if the contrasts are correctly
constructed). You can only see the effect of contrasts when you look at the
single coefficients. This is exactly the same in standard lm(), glm() etc.

Cheers, Jari



More information about the R-sig-ecology mailing list