--- title: "hawks" author: "Chris Parrish" date: "January 20, 2016" output: pdf_document --- hawks references: - Cannon, et al., Stat2, chapter 05, example 5.9 Import the data. ```{r} data <- read.csv("Hawks.csv", header=TRUE) head(data, 3) dim(data) ``` View the data. ```{r} plot(Tail ~ Species, data=data, horizontal=TRUE, col=terrain.colors(3), las=1, xlab="", ylab="Tail length") ``` Group statistics. ```{r} n <- with(data, tapply(Tail, Species, length)) mean <- with(data, round(tapply(Tail, Species, mean), 3)) sd <- with(data, round(tapply(Tail, Species, sd), 3)) hawks.statistics <- cbind(n, mean, sd) hawks.statistics grand.mean <- cbind(n = length(data\$Tail), mean = mean(data\$Tail), sd = sd(data\$Tail)) rownames(grand.mean) <- c("Total") grand.mean <- round(grand.mean, 3) grand.mean ``` Model: ANOVA with `aov` ```{r} hawks.aov <- aov(Tail ~ Species, data=data) hawks.aov options(show.signif.stars=FALSE) summary(hawks.aov) ``` Residuals. ```{r} plot(predict(hawks.aov), resid(hawks.aov), pch=20, col="darkred") qqnorm(resid(hawks.aov), col="cadetblue") qqline(resid(hawks.aov), col="orange") library(lattice) dotplot(Tail ~ Species, data=data, jitter=TRUE) ``` ```{r fig.width=6, fig.height=5.6} stripchart(Tail ~ Species, data=data, pch=20, cex=0.8, las=1, col="darkred", method="stack") std.dev <- hawks.statistics[ , 3] std.dev ratio <- max(std.dev) / min(std.dev) ratio ``` Note the bimodal tail length distributions for the two *Accipiters*. Female Sharp-shinned Hawks and Cooper's Hawks have longer tails.