pairwise and morphol.disparity

214 views
Skip to first unread message

jessica...@gmail.com

unread,
Apr 17, 2021, 4:48:52 PM4/17/21
to geomorph R package
Hi,

I am getting different pairwise and morphol.disparity procrustes variance outputs for a procD.pgls object. I ran a similar analysis with the example data (which I pasted bellow) to confirm that it was not just a issue with my specific dataset. In my case, I'm getting significant differences using morphol.disparity and not so when using pairwise. I hope you can help me understand this difference, I've read the help files but couldn't figure it out by myself. Also, I learn a lot from this community, thank you all.

I'm using R 4.0.5, geomorph 4.0.0, RRPP 1.0.0

data(plethspecies)
Y.gpa<-gpagen(plethspecies$land)  
gp.end<-factor(c(0,0,1,0,0,1,1,0,0))
names(gp.end)<-plethspecies$phy$tip

gdf <- geomorph.data.frame(Y.gpa, phy = plethspecies$phy, gp.end = gp.end)
pleth.pgls <- procD.pgls(coords ~ Csize * gp.end, phy = phy, data = gdf, iter = 999)

pw<-pairwise(pleth.pgls,groups=gdf$gp.end, print.progress=F)
summary(pwt, test.type="var", confidence=0.95, stat.table=F)

morphol.disparity(f1 = pleth.pgls, groups = ~ gp.end, data = gdf, iter = 999, print.progress = FALSE)

Pairwise output
Observed variances by group
          0           1
0.002153583 0.001570511

Pairwise distances between variances
             0            1
0 0.0000000000 0.0005830723
1 0.0005830723 0.0000000000

morphol.disparity output
Procrustes variances for defined groups
           0            1
0.0004061528 0.0001983589

Pairwise absolute differences between variances
             0            1
0 0.0000000000 0.0002077938
1 0.0002077938 0.0000000000

Mike Collyer

unread,
Apr 17, 2021, 5:47:08 PM4/17/21
to geomorph-...@googlegroups.com
Hi Jessica,

Thanks for catching this.  The difference in results is because of a subtle difference in how the mean of squared Procrustes residuals (variance) is calculated.  Although both functions use GLS residuals, pairwise performs a GLS transformation of the means and morphol.disparity does not.  The former is a better estimate of variance; the latter might be a better estimate of disparity (variation around the GLS mean).

The geomorph team might have to confer on this and decide if one has to be corrected.  I think morphol.disparity does what it always has done but if PGLS is performed, the GLS means rather than the OLS means should be used.  In pairwise, the function is measuring group variances.  For GLS, the mean squared distances from the GLS mean and the variance are actually different things (the latter is the mean of squared transformed residuals).

Regardless, it was not intentional to have these be different — just overlooked that they would be.  We either have to warn that they are not the same in notes or decide to transform the residuals in a function update.  Hopefully, in the interim, you have some knowledge to decide which you prefer to use.

Cheers!
Mike


--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/1e7177a9-3cc0-4a3d-a00d-6301a973ff59n%40googlegroups.com.

Jéssica Fratani

unread,
Apr 18, 2021, 10:39:19 AM4/18/21
to geomorph-...@googlegroups.com
Thank you Mike!

With your response I realized that I mix up the concepts of variance and disparity, so I'll read a bit more, stick with pairwise results for now and wait for the geomorph team to decide what's best.

Cheers,
Jessica

You received this message because you are subscribed to a topic in the Google Groups "geomorph R package" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geomorph-r-package/l174PGZZMLs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/geomorph-r-package/8893186D-C96A-4C35-910A-515B2BC55BF3%40gmail.com.


--
Jéssica Fratani
Instituto de Herpetología
Unidad Ejecutora Lillo, CONICET - FML
Miguel Lillo 251 (4000)
Tucumán - Argentina

Mike Collyer

unread,
Apr 19, 2021, 4:26:57 PM4/19/21
to geomorph-...@googlegroups.com
Dear Jéssica, and everyone,

Thanks again, Jéssica, for catching the difference between disparity and variance for GLS models.  I was reminded when looking at the help file that we mentioned that disparity using GLS residuals is different than measuring variance, but after some thought, it seemed to make more sense to give the user the ability to decide whether to transform residuals.  Therefore, we have added an argument, transform, that if FALSE provides the group disparities in the tangent space, like morphol.disparity did before the adjustment; if TRUE, the residuals are transformed, making them independent of phylogeny, such that disparity measured on these are the same as GLS variance (matches what the pairwise function does).

Another way to think about this is that if one performed a phylogenetic PCA, pPCA, transform = FALSE, then the disparity done this way tracks the dispersion of points seen in a pPC plot.  If one does a PCA of values projected into a transformed space (independent of phylogeny), tpPCA, the transform = TRUE version of disparity matches group variances, and tracks the dispersion of points in the tpPC plot.  We discuss this a bit in our recent article, Collyer, M.L and D.C. Adams, 2021. Phylogenetically Aligned component analysis. Methods in Ecology and Evolution, 12: 369-372.

These updates have been made on the Github version of geomorph.  We hope that this additional argument will be useful.

Cheers!
Mike

Reply all
Reply to author
Forward
0 new messages