### This will draw the correlogram from Gittleman and Kot 1990
### This is only for example, consider function plot.correlogram()
### to draw correlograms.
data(carnivora)
attach(carnivora)
# Compute distance matrix for each taxonomic level:
dG <- weight.taxo(Genus)
dF <- weight.taxo(Family)
dSF <- weight.taxo(SuperFamily)
dO <- weight.taxo(Order)
# We draw the correlogram of average body weights,
# with log10-transformed variable:
IG <- Moran.I(log10(SW), dG , scale=TRUE)
IF <- Moran.I(log10(SW), dF & !dG , scale=TRUE)
ISF <- Moran.I(log10(SW), dSF & !dF , scale=TRUE)
IO <- Moran.I(log10(SW), dO & !dSF, scale=TRUE)
# All Moran's I indices:
i <- c(IG$obs, IF$obs, ISF$obs, IO$obs)
# With their corresponding p-values:
p <- c(IG$p.v, IF$p.v, ISF$p.v, IO$p.v)
# Here's the legend:
l <- c("G", "F", "SF", "O")
# Draw the correlogram (using lattice library):
library(lattice)
# New Black & White device:
trellis.device(device=X11, new=FALSE, color=FALSE)
# Black circles are significant at the 5% level:
pch <- ifelse(p < 0.05, 19, 21)
# Plot it!
xyplot(i~ordered(l,levels=l), type="b", xlab="Rank", ylab="I / Imax",
lty=2, lwd=2, cex=1.5, pch=pch, ylim=c(-0.75,0.75))
Run the code above in your browser using DataLab