[R-sig-eco] Is adonis the right test for me?

Jari Oksanen jari.oksanen at oulu.fi
Tue Feb 7 10:55:16 CET 2012


Eduard,

In reading current R discussion, I suddenly remembered that you had sent me your SIMPER code. I had a quick look at it, and it looks like being quite OK for inclusion in vegan if you so wish (perhaps after minor editing). Do you wish to have this in vegan? The help page would naturally give you as the author of the function.

I think I'm going to have a next release of vegan (2.0-3) sometimes in February. There have not been any noteworthy bugs nor any more extensive changes in the release branch, and having this would probably push the release closer. There are large changes in the development branch, and we need to clean the table with minor stable releases to be able to have a larger update of vegan (to 2.2-0).

Cheers, Jari Oksanen 


On 29/04/2011, at 13:03 PM, Eduard Szöcs wrote:

> Hai Kari,
> 
> as far as i know SimPer is not available in vegan.
> 
> I have written some code for myself a few months ago to do this.
> I think its doing the job, but coding is poor (3 for-loops...).
> 
> 
> - Eduard
> 
> 
> ############################################################
> ######         SIMPER      , Clarke (1993)                           
>            ########
> ###### V 0.3   29.04.2011  Szöcs, Eduard                                 
> ########
> ############################################################
> 
> 
> ###############
> #### Code #####
> ###############
> 
> simper <- function(comm, groups, select){
>   group.a <- as.matrix(comm[groups == select[1], ])
>   group.b <- as.matrix(comm[groups == select[2], ])
>   n.a <- nrow(group.a)
>   n.b <- nrow(group.b)
>   P <- ncol(comm)
>   me <- matrix(ncol = P)
>   md <- matrix(ncol = P)
>   contr <- matrix(ncol = P, nrow = n.a * n.b)
>   for(j in 1:n.b) {
>       for(k in 1:n.a) {
>           for(s in 1:P) {
>               md[s] <- abs(group.a[k, s] - group.b[j, s])
>               me[s] <- group.a[k, s] + group.b[j, s]
>               a <- rowSums(me)
>               c <- md / a
>               contr[(j-1)*n.a+k, ] <- md / a
>   }}}
>   av.contr <- apply(contr, 2, mean)*100
>   ov.av.dis <- sum(av.contr)
>   sdi <- apply(contr, 2, sd)
>   sdi.av <- sdi / av.contr
>   av.a <- colMeans(group.a)
>   av.b <- colMeans(group.b)
>   dat <- data.frame(av.contr, sdi, sdi.av, av.a, av.b)
>   dat <- dat[order(dat$av.contr, decreasing = TRUE),]
>   cum <-  cumsum(dat$av.contr / ov.av.dis)*100
>   out <- data.frame(dat, cum)
>   out
> }
> 
> 
> ###############
> #### Usage ####
> ###############
> 
> #  simper(comm, groups, select)
> 
> # Arguments :
> ############
> 
> #   * comm : commumity data. species in columns, observations in rows
> #   * groups : vector containing treatment per observation
> #   * select : vector with length 2, indicating the two groups to compare
> 
> 
> # Output :
> ##########
> 
> #   * av.contr : average contribution to overall similarity
> #   * sdi : standard deviation of contribution
> #   * sdi.va : ratio mean / sd = sdi / av.contr.
> #   * av.a : average abundance in first group
> #   * av.b : average abundance in second group
> #   * cum : cumulative contribution
> 
> 
> #################
> #### Example ####
> #################
> 
> require(vegan)
> data(dune)
> data(dune.env)
> adonis(dune ~ Management, data=dune.env, permutations=99)
> levels(dune.env$Management)
> simper(dune, dune.env$Management, c("BF", "SF"))
> 
> 
> 
> 
> Am 29.04.2011 06:34, schrieb Kari Lintulaakso:
>> Dear list,
>> 
>> I'm not so familiar with ecological statistics (though I should be),
>> so I'm looking for a confirmation and support to my decision to move
>> on with the adonis path.
>> 
>> I've been trying to find a method to analyse differences between
>> mammalian communities and I think adonis would do the work for me.
>> 
>> My data consists of different localities (each of assigned into a
>> vegetation class) and number of species in different ecomorphological
>> classes (groups) I have generated.
>> There are nine vegetation classes, 52 localities, six mammalian groups
>> having some 200-300 species in them.
>> My idea is to use these mammalian groups as "species" in the data
>> matrix which would look like this:
>> 
>> L	V	G1	G2	G3	...	G6
>> 1	1	0	1	2	...	8
>> 2	2	1	2	1	...	3
>> 3	2	1	3	2	...	4
>> 4	3	5	2	2	...	9
>> 5	3	5	3	3	...	8
>> 6	3	4	2	3	...	7
>> ...		
>> 52	9	8	8	1	...	0
>> 
>> L=locality id
>> V = vegetation class
>> G1...G6 mammalian groups, and in the matrix the counts of species in the group.
>> 
>> First I'm trying to test if there are any differences between the
>> vegetation groups. For this I'm planning to use a pairwise adonis
>> comparisons between the different vegetation groups, i.e V1 vs V2, V1
>> vs V3, ... V8 vs V9. From each of these comparisons I'm taking the Df,
>> F, P>F etc values into a matrix so that I'm able to see the values
>> later.
>> 
>> When I get the P-values I suppose I can say that there are differences
>> between the vegetation classes when the P-value is<  0.05, right?
>> And if so, I need to find a way to explain which mammalian groups are
>> responsible for these differences? Does anyone have a good suggestion
>> for this? I've found one approach which is called SimPer (Similarity
>> Percentage Analysis), but I'm not sure is it in vegan.
>> 
>> And finally, is there any requirement, how many different data rows I
>> need for one type of vegetation? In some cases I only have one which
>> would mean that the within group variation is zero?
>> 
>> Any suggestions are welcome!
>> -Kari
>> 
>> Kari Lintulaakso, M.Sc.(Biosciences)
>> 
>> Doctoral student
>> Paleontology and Paleoecology
>> Department of Geosciences and Geography
>> University of Helsinki
>> 
>> * Email: kari.lintulaakso at helsinki.fi
>> * Post: Department of Geology, Gustaf Hällströmin katu 2a (P.O Box
>> 64), 00014 University of Helsinki
>> * Web page: http://blogs.helsinki.fi/lintulaa/
>> 
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>> 
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

-- 
Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
jari.oksanen at oulu.fi, Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa



More information about the R-sig-ecology mailing list