# NOT RUN {
data(lizards)
# }
# NOT RUN {
##log-linear model as in Burnham and Anderson 2002, p. 137
##main effects
m1 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species,
family = poisson, data = lizards)
##main effects and all second order interactions = base
m2 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Time +
Diameter:Species + Height:Time + Height:Species +
Time:Species, family = poisson, data = lizards)
##base - DT
m3 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Species +
Height:Time + Height:Species + Time:Species,
family = poisson, data = lizards)
##base + HDI + HDT + HDS
m4 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Time +
Diameter:Species + Height:Time + Height:Species +
Time:Species + Height:Diameter:Insolation +
Height:Diameter:Time + Height:Diameter:Species,
family = poisson, data = lizards)
##base + HDI + HDS + HIT + HIS + HTS + ITS
m5 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Time +
Diameter:Species + Height:Time + Height:Species +
Time:Species + Height:Diameter:Insolation +
Height:Diameter:Species + Height:Insolation:Time +
Height:Insolation:Species + Height:Time:Species +
Insolation:Time:Species, family = poisson, data = lizards)
##base + HIT + HIS + HTS + ITS
m6 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Time +
Diameter:Species + Height:Time + Height:Species +
Time:Species + Height:Insolation:Time +
Height:Insolation:Species + Height:Time:Species +
Insolation:Time:Species, family = poisson, data = lizards)
##base + HIS + HTS + ITS
m7 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Time +
Diameter:Species + Height:Time + Height:Species +
Time:Species + Height:Insolation:Species +
Height:Time:Species + Insolation:Time:Species,
family = poisson, data = lizards)
##base + HIT + HIS + HTS + ITS - DT
m8 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Species +
Height:Time + Height:Species + Time:Species +
Height:Insolation:Time + Height:Insolation:Species +
Height:Time:Species + Insolation:Time:Species,
family = poisson, data = lizards)
##base + HIT + HIS + ITS - DT
m9 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Species +
Height:Time + Height:Species + Time:Species +
Height:Insolation:Time + Height:Insolation:Species +
Insolation:Time:Species,
family = poisson, data = lizards)
##base + HIT + HIS - DT
m10 <- glm(Counts ~ Insolation + Diameter + Height + Time + Species +
Insolation:Diameter + Insolation:Height + Insolation:Time +
Insolation:Species + Diameter:Height + Diameter:Species +
Height:Time + Height:Species + Time:Species +
Height:Insolation:Time + Height:Insolation:Species,
family = poisson, data = lizards)
##set up in list
Cands <- list(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10)
Modnames <- paste("m", 1:length(Cands), sep = "")
##model selection
library(AICcmodavg)
aictab(Cands, Modnames)
# }
Run the code above in your browser using DataLab