Objective
For this lab, you will analyze data collected in 2004 from the saw-whet owl banding station at HMF. Your analyses will come from the list of objectives outlined in Drew Jones' presentation:
- Overall Population; trends
- Age structure
- Age/spatial patterns
- Time effects on Age/sex
- Morphology
- Movement—recaptures
- Phenology
- Longevity, Survivorship
- Weather effects
- Moon phase effects
Your assignment is to (1) pick three analyses from the list of questions posed by Drew that interest you, (2) develop corresponding hypotheses, (3) graph (or otherwise appropriately present) the data, (4) test your hypotheses, and (5) generate conclusions from your results.
Methods
To help you choose the appropriate statistical test to use, I have prepared a statistics "key" for you:
- Continuous Response, e.g. weight, chord, etc. (Note: See details below for instructions related to analyzing Owl Capture data)
- lm(response~predictor)
- Categorical Response, e.g. eye color, age, etc.
- Continuous Predictor
- glm(response~predictor, family=binomial)
- Use this “family” option for categorical responses with 2 levels
- glm(response~predictor, family=poisson)
- Use this “family” option for categorical responses with > 2 levels
- Categorical Predictor
- chisq.test(table(response,predictor))
Examples
For the examples below, you will need to load the data file for 2004. Download weather data here and owl data here. Then:
data <- read.csv("Owl_Data_2004.csv")
## Import weather data
weather <- read.csv("Weather_2004.csv")
## Remember to use head(data) or summary(data) to "see" the data
1.1: Continuous response (continuous or categorical predictor).
plot(weight~length, data=data) # Start by plotting the data result_1.1 <- lm(weight~length, data=data) # Linear regression anova(result_1.1) # To get P-values summary(result_1.2) # Also yields P-values
Note that the Owl Capture data represent a special case because although more or less continuous, the data are discrete. It turns out that it is preferable to use a model with "poisson errors" for the analysis of these data. Moreover, we may be interested in evaluating the effect of various environmental conditions on Owl Captures after taking into account the effect of seasonality. To do this, we may want to smooth the data to remove the seasonal trend in abundance, and then ask what environmental factors predict capture success ... e.g., maybe not warm cloudy nights :-(
library(splines) # May need to install as described in previous labs freqs <- hist(as.Date(data$date), breaks="days", freq=TRUE) ## Create data file for analysis data.capture <- data.frame(date=freqs$mids, counts=freqs$counts, weather[1:41,]) ## Analysis result_1.2.1 <- glm(counts~ns(date,3), family=poisson, data=data.capture) ## Add prediction line based on season lines(exp(predict(result_1.2.1))~date, col="blue", data=data.capture)
To expand on this base "seasonality" model, you would add predictors in addition to the ns(date,3) predictor (which adds a smoothing spline to the data). For example:
## Add temperature to the base model ## Note that you will not be able to add the predicted values from this ## analysis to the previous plot. result_1.2.2 <- glm(counts~ns(date,3)+temp, family=poisson, data=data.capture) summary(result_1.2.2) # To get P-values
2.1.1: Categorical response, continuous predictor, binomial (2-level) outcome.
fac2bin <- function(x) as.numeric(x)-min(as.numeric(x)) # Conversion function
predictor <- fac2bin(data$color) # Convert "HO","BL"
# to 0,1
## Import plotting function published in volume 86(1) of the Bulletin of the
## Ecological Society of America
## http://www.esapubs.org/bulletin/backissues/086-1/bulletinjan2005.htm#et
source("http://mutualism.williams.edu/Files/plot.logi.hist.R")
plot.logi.hist(data$weight,predictor)
result_2.1.1 <- glm(color~weight, data=data, family="binomial")
summary(result_2.1.1) # To get P-values
2.1.2: Categorical response, continuous predictor, multinomial (>2-level) outcome. Note the difference in the option family from above.
result_2.1.2 <- glm(fat~weight, data=data, family="poisson") summary(result_2.1.2) # To get P-values
2.2 Categorical response, categorical predictor:
table(data$fat,data$age) # Convert to a table of frequencies chisq.test(table(data$fat,data$age)) # Note warning in P-value from approximation chisq.test(table(data$fat,data$age), simulate.p.value=TRUE)

