Hi all,
I am comparing species data for plots and using cluster analysis to determine forest structural groupings. After having done this analysis in PC-ORD, I was curious about doing the same analysis in R using the vegan and cluster packages. After spending some time learning the R packages and how to select the right parameters, I am able to replicate the distance matrix in R, but when I try to run the cluster analysis using the same parameters as PC-ORD I am getting similar but different results. Now I'm not sure which program is "right".
Prior to running the analysis, I do a general relativization across rows, and in the cluster analysis I use the Sorenson (B-C) distance measure and flexible beta linkage, with beta = -0.25 and for example comparison using a group membership level = 6. And here is the code I am using in R from the vegan and cluster packages, where matrix is my plot/species raw data:
matrix_rel<-matrix[,c(1,2)] #Add in plot identifiers
matrix_rel[,c(3:14)]<-sapply(matrix[c(3:14)], function(x) x/rowSums(matrix[c(3:14)])) #general relativization of the data by row.
distance<-vegdist(matrix_rel[,c(3:14)], method = "bray") #calculate B-C distance matrix
tree_clust<-agnes(distance,method = "flexible", par.method=c(0.625,0.625,-0.25)) #run cluster analysis
tree_clust<-as.hclust(tree_clust)
matrix$FT6<-cutree(tree_clust, k=6) #cut dendrogram into 6 groups and add to original matrix.
Additionally, I am then using MRPP to determine within-group similarities and to determine the optimal number of groups produced by the cluster analysis, primarily interested in the A value. Again, I am getting different results in R vs PC-ORD even when importing the PC-ORD identified groups into R and doing the MRPP, the A value is quite different. I am getting A=0.507 in PC-ORD and A=0.3041 in R on the same groups. The parameters I'm using here are again Sorenson (B-C) and a weighting of n/sum(n) and the vegan package, with the R code:
mrpp(matrix[,3:14], matrix$FT6, distance="bray")
If someone could shed some light on what is going on here that would be extremely helpful.
Thanks in advance for your help,
Aaron