[R-sig-eco] PERMANOVA and adonis: trying to clear my confusion
Steve Brewer
jbrewer @ending from olemi@@@edu
Tue Jan 8 15:11:39 CET 2019
I’ve generated a function called “centroidmatrix” that might be helpful to you. I think this could allow you to test the season and habitat and their interaction effects using the correct error term.
#' centroidmatrix
#' This function allows you to generate a matrix of centroids from a non-Euclidean distance matrix using the betadisper function in vegan.
#' @param factorname The name of a treatment factor file containing the treatment factors and other sources of variation and a grouping variable for calculation of centroids in the columns and observations in rows
#' @param speciesname The name of species file which has species in columns and observations in rows in the same order as in the factorname file and of the same length
#' @param groupvarname The name of the grouping variable in the factorname file for which centroids are calculated
#' @param distancetype The type of distance or dissimilarity matrix to be calculated from the species file using the vegdist function in vegan Default is "bray"
#' @export
#' @examples
#' centroidmatrix()
centroidmatrix <- function(factorname, speciesname, groupvarname, distancetype){
groupvar <- factor(groupvarname)
braydist <- vegdist(speciesname, method = distancetype)
betadisperout <- betadisper(braydist, groupvar, type = 'centroid')
braycent <- betadispout$centroids
return(braycent)
}
Stephen Brewer
jbrewer using olemiss.edu<mailto:jbrewer using olemiss.edu>
Professor
Department of Biology
PO Box 1848
University of Mississippi
University, Mississippi 38677-1848
Brewer web page - https://jstephenbrewer.wordpress.com
FAX - 662-915-5144 Phone - 662-202-5877
On Jan 8, 2019, at 7:49 AM, Pedro Neves <pedro.neves using oom.arditi.pt<mailto:pedro.neves using oom.arditi.pt>> wrote:
On 08/01/19 09:59, Pedro Neves wrote:
Assuming that my species data is Spec_data and the factors data is Env_data, my formulation is:
adonis(Spec_data ~ Season * Habitat/Location, strata=Habitat, data=Env_data, method="bray")
Is this formulation correct, according to my experimental design?
Hi again:
In trying to respond to my own question, I compared the results of the PERMANOVA obtained with R:vegan and using the original FORTRAN program from Marti Anderson and Primer 6+.
The results from R are different from the ones obtained with the other two programs and the difference on the degrees of freedom with R, clearly indicate that the formula is incorrect:
Results from R (using adonis2(formula = Spec_data ~ Season * Habitat/Location, data = Env_data, method = "bray", by = "terms", strata = Habitat):
Df SumOfSqs R2 F Pr(>F)
------------------------------------------------------------------------------------------
Season 1 1.4465 0.07112 50.360 0.001 ***
Habitat 1 5.9292 0.29150 206.425 0.001 ***
Season:Habitat 1 0.7575 0.03724 26.373 0.001 ***
Season:Habitat:Local 4 4.3942 0.21604 38.246 0.001 ***
Residual 272 7.8127 0.38410
Total 279 20.3401 1.00000
-------------------------------------------------------------------------------------------
Results from PERMANOVA (original FORTRAN code):
Source df SS MS F P(perm) P(MC)
-----------------------------------------------------------------------------
Se 1 14029.6135 14029.6135 1.5637 0.2592 0.2358
Ha 1 56723.5220 56723.5220 4.2938 0.0002 0.0188
Lo(Ha) 2 26421.0270 13210.5135 28.1272 0.0002 0.0002
SexHa 1 7504.5849 7504.5849 0.8364 0.3864 0.5542
SexLo(Ha) 2 17944.4582 8972.2291 19.1032 0.0002 0.0002
Residual 272 127750.3725 469.6705
Total 279 250373.5780
-----------------------------------------------------------------------------
Results from PRIMER:
PERMANOVA table of results
Unique
Source df SS MS Pseudo-F P(perm) perms P(MC)
------------------------------------------------------------------------------------------------------------------------
Se 1 14465 14465 1,8194 0,3153 51 0,2024
Ha 1 12752 12752 0,34679 0,6594 3 0,8376
Lo(Ha) 2 73540 36770 128,01 0,0002 4982 0,0002
SexHa 1 8616,6 8616,6 1,0838 0,3414 51 0,4186
SexLo(Ha) 2 15901 7950,4 27,679 0,0002 4980 0,0002
Res 272 78127 287,23
Total 279 2,034E5
--------------------------------------------------------------------------------------------------------------------------
What am I missing in R formulation?
Thanks in advance:
Pedro
_______________________________________________
R-sig-ecology mailing list
R-sig-ecology using r-project.org<mailto:R-sig-ecology using r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[[alternative HTML version deleted]]
More information about the R-sig-ecology
mailing list