if (FALSE) {
### Analysis of sexual dimorphism vectors (factorial approach)
data(Pupfish)
fit <- lm.rrpp(coords ~ Pop * Sex, data = Pupfish, iter = 199)
reveal.model.designs(fit)
TA <- trajectory.analysis(fit, groups = Pupfish$Pop,
traj.pts = Pupfish$Sex, print.progress = FALSE)
# Magnitude difference (absolute difference between path distances)
summary(TA, attribute = "MD")
# Correlations (angles) between trajectories
summary(TA, attribute = "TC", angle.type = "deg")
# No shape differences between vectors
summary(TA, attribute = "SD")
# Retain results
TA.summary <- summary(TA, attribute = "MD")
TA.summary$summary.table
# Plot results
TP <- plot(TA, pch = as.numeric(Pupfish$Pop) + 20, bg = as.numeric(Pupfish$Sex),
cex = 0.7, col = "gray")
add.trajectories(TP, traj.pch = c(21, 22), start.bg = 1, end.bg = 2)
legend("topright", levels(Pupfish$Pop), pch = c(21, 22), pt.bg = 1)
### Analysis when data are already trajectories (motion paths)
# data are planar Cartesian coordinates (x, y) across 5 points (10 variables)
data(motionpaths)
fit <- lm.rrpp(trajectories ~ groups, data = motionpaths, iter = 199)
TA <- trajectory.analysis(fit, groups = motionpaths$groups, traj.pts = 5)
# Magnitude difference (absolute difference between path distances)
summary(TA, attribute = "MD")
# Correlations (angles) between trajectories
summary(TA, attribute = "TC", angle.type = "deg")
# Shape differences between trajectories
summary(TA, attribute = "SD")
TP <- plot(TA, pch = 21, bg = as.numeric(motionpaths$groups),
cex = 0.7, col = "gray")
add.trajectories(TP, traj.pch = 21, traj.bg = 1:4)
}
Run the code above in your browser using DataLab