if (FALSE) {
# Examples use geometric morphometric data on pupfishes
# See the package, geomorph, for details about obtaining such data
# Body Shape Analysis (Multivariate) --------------
data("Pupfish")
# Note:
dim(Pupfish$coords) # highly multivariate!
Pupfish$logSize <- log(Pupfish$CS)
# Note: one should use all dimensions of the data but with this
# example, there are many. Thus, only three principal components
# will be used for demonstration purposes.
Pupfish$Y <- ordinate(Pupfish$coords)$x[, 1:3]
## Pairwise comparisons of LS means
# Note: one should increase RRPP iterations but a
# smaller number is used here for demonstration
# efficiency. Generally, iter = 999 will take less
# than 1s for these examples with a modern computer.
fit1 <- lm.rrpp(Y ~ logSize + Sex * Pop, SS.type = "I",
data = Pupfish, print.progress = FALSE, iter = 199)
summary(fit1, formula = FALSE)
anova(fit1)
pup.group <- interaction(Pupfish$Sex, Pupfish$Pop)
pup.group
PW1 <- pairwise(fit1, groups = pup.group)
PW1
# distances between means
summary(PW1, confidence = 0.95, test.type = "dist")
summary(PW1, confidence = 0.95, test.type = "dist", stat.table = FALSE)
# absolute difference between mean vector lengths
summary(PW1, confidence = 0.95, test.type = "DL")
# correlation between mean vectors (angles in degrees)
summary(PW1, confidence = 0.95, test.type = "VC",
angle.type = "deg")
# Can also compare the dispersion around means
summary(PW1, confidence = 0.95, test.type = "var")
## Pairwise comparisons of slopes
fit2 <- lm.rrpp(Y ~ logSize * Sex * Pop, SS.type = "I",
data = Pupfish, print.progress = FALSE, iter = 199)
summary(fit2, formula = FALSE)
anova(fit1, fit2)
# Using a null fit that excludes all factor-covariate
# interactions, not just the last one
PW2 <- pairwise(fit2, fit.null = fit1, groups = pup.group,
covariate = Pupfish$logSize, print.progress = FALSE)
PW2
# distances between slope vectors (end-points)
summary(PW2, confidence = 0.95, test.type = "dist")
summary(PW2, confidence = 0.95, test.type = "dist", stat.table = FALSE)
# absolute difference between slope vector lengths
summary(PW2, confidence = 0.95, test.type = "DL")
# correlation between slope vectors (and angles)
summary(PW2, confidence = 0.95, test.type = "VC",
angle.type = "deg")
# Can also compare the dispersion around group slopes
summary(PW2, confidence = 0.95, test.type = "var")
}
Run the code above in your browser using DataLab