Function estimates morphological disparity and performs pairwise comparisons among groups.

1 2 |

`f1` |
A formula describing the linear model used. The left-hand portion of the formula should be a 3D array (p x k x n) containing GPA-aligned coordinates for a set of specimens, or a matrix (n x variables). The right-hand portion of the formula should be " ~1" to use the overall mean, or "~ x1 + x2 + x3 +...", where each x is a covariate or factor. (Interactions and nested terms also work.) |

`groups` |
A formula designating groups, e.g., groups = ~ groups. If NULL, morphol.disparity will attempt to define groups based on the linear model formula, f1. If there are no groups inherently indicated in f1 and groups is NULL, a single Procrustes variance will be returned for the entire data set. |

`iter` |
Number of iterations for permutation test |

`seed` |
An optional argument for setting the seed for random permutations of the resampling procedure. If left NULL (the default), the exact same P-values will be found for repeated runs of the analysis (with the same number of iterations). If seed = "random", a random seed will be used, and P-values will vary. One can also specify an integer for specific seed values, which might be of interest for advanced users. |

`data` |
A data frame for the function environment, see |

`print.progress` |
A logical value to indicate whether a progress bar should be printed to the screen. This is helpful for long-running analyses. |

`...` |
Arguments passed on to procD.fit (typically associated with the lm function) |

The function estimates morphological disparity and performs pairwise comparisons to identify differences
between groups. Morphological disparity is estimated as the Procrustes variance, overall or for groups,
using residuals of a linear model fit. Procrustes variance is the same sum of the diagonal elements
of the group covariance matrix divided by the number of observations in the group (e.g., Zelditch et al. 2012).
The function takes as input a formula to describe the linear model fit,
plus a formulaic indication of groups (e.g., ~ groups). It is assumed that the formula describes shape data that
have been GPA-aligned [e.g., `gpagen`

], although the function can work with any multivariate data.

Absoluted differences in Procrustes variances are test statistics that can be used to test differences in morphological disparity among groups. These differences are statistically evaluated through permutation, where the vectors of residuals are randomized among groups. The function can be used to obtain disparity for the whole dataset by using "a dummy group factor "~ 1" as the right-hand portion of the formula, in which case only Procrustes variance is returned. Additionally, if the right-hand portion of the formula only contains (continuous) covariates, e.g., "~ Csize", Procrustes variance will be calculated for the whole data set or groups, after accounting for the linear regression described. Finally, different factors can be indicated in the formula and for groups, if one wishes to compare morphological disparities for groups comprising only a portion of or collapsing of the groups in a more complex model (see examples).

Objects of class "morphol.disparity" return a list with the following components (if groups are specified):

`Procrustes.var` |
Observed Procrustes variances. |

`PV.dist` |
Observed pairwise absolute differences (distances) among group Procrustes variances. |

`PV.dist.Pval` |
P-values associated with pairwise differences. |

`random.PV.dist` |
Pairwise distance matrices produced in the resampling procedure. |

`permutations` |
Number of random permutations in resampling procedure. |

`call` |
The match call |

Emma Sherratt and Michael Collyer

Zelditch, M. L., D. L. Swiderski, H. D. Sheets, and W. L. Fink. 2012. Geometric morphometrics for biologists: a primer. 2nd edition. Elsevier/Academic Press, Amsterdam.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
data(plethodon)
Y.gpa<-gpagen(plethodon$land) #GPA-alignment
gdf <- geomorph.data.frame(Y.gpa, species = plethodon$species, site = plethodon$site)
# Morphological disparity for entire data set
morphol.disparity(coords ~ 1, groups= NULL, data = gdf, iter=999)
# Morphological disparity for entire data set, accounting for allometry
morphol.disparity(coords ~ Csize, groups= NULL, data = gdf, iter=999)
# Morphological disparity without covariates, using overall mean
morphol.disparity(coords ~ 1, groups= ~ species*site, data = gdf, iter=999)
# Morphological disparity without covariates, using group means
morphol.disparity(coords ~ species*site, groups= ~species*site, data = gdf, iter=999)
# Morphological disparity of different groups than those described by the linear model
morphol.disparity(coords ~ Csize + species*site, groups= ~ species, data = gdf, iter=999)
# Extracting components
MD <- morphol.disparity(coords ~ Csize + species*site, groups= ~ species, data = gdf, iter=999)
MD$Procrustes.var # just the Procrustes variances
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.