Schoener's Lizards: A Complex Contingency Table

In this section we are interested in whether lizards show any niche separation across various ecological factors and, in particular, whether there are any interactions – for example, whether they show different habitat separation at different times of day.

lizards<-read.table("c:\\temp\\lizards.txt",header=T)
attach(lizards)
names(lizards)

[1] "n" "sun" "height" "perch" "time" "species"

The response variable is n, the count for each contingency. The explanatory variables are all categorical: sun is a two-level factor (Sun and Shade), height is a two-level factor (High and Low), perch is a two-level factor (Broad and Narrow), time is a three-level factor (Afternoon, Mid.day and Morning), and there are two lizard species both belonging to the genus Anolis (A. grahamii and A. opalinus). As usual, we begin by fitting a saturated model, fitting all the interactions and main effects:

model1<-glm(n~sun*height*perch*time*species,poisson)

Model simplification begins with removal of the highest-order interaction effect: the sun-by-height-by-perch-by-time-by-species interaction (!):

model2<-update(model1, ~.- sun:height:perch:time:species)
anova(model1,model2,test="Chi")

Analysis of Deviance Table

   Resid. Df  Resid. Dev   Df   Deviance   P(>|Chi|)
1          0   3.348e-10
2          2   2.181e-10   -2  1.167e-10           1

It is a considerable relief that this interaction is not significant (imagine trying to explain what it meant in the Discussion section of your paper). The ...

Get The R Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.