### snail additional analyses exercise
# preliminaries
library(MASS)
data(snails)
spA<-snails[1:48,]; spB<-snails[48:96,]
snails$deadORalive<-cbind(snails$Deaths,20-snails$Deaths)
# ignoring interactions
par(mfrow=c(2,2))
m3<-glm(deadORalive ~ Species+Temp+Rel.Hum, family=quasibinomial, data=snails)
plot(m3)
summary(m3)
#Call:
#glm(formula = deadORalive ~ Species + Temp + Rel.Hum, family = quasibinomial,
# data = snails)
#
#Deviance Residuals:
# Min 1Q Median 3Q Max
#-4.451 -2.050 -1.086 1.482 3.746
#
#Coefficients:
# Estimate Std. Error t value Pr(>|t|)
#(Intercept) 2.04946 1.64006 1.250 0.214606
#SpeciesB 1.02829 0.28270 3.637 0.000454 ***
#Temp 0.07257 0.03313 2.191 0.030997 *
#Rel.Hum -0.08290 0.02363 -3.508 0.000700 ***
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
#(Dispersion parameter for quasibinomial family taken to be 3.884657)
#
# Null deviance: 539.72 on 95 degrees of freedom
#Residual deviance: 417.15 on 92 degrees of freedom
#AIC: NA
#
#Number of Fisher Scoring iterations: 5
## We can see that the two species differ significantly in terms of overall mortality
## as we could easily see from the initial barplots, spB suffered overall far higher mortality.
## Next we see in terms of significance that relative humidity had a strong effect on survival,
## but the effect of temperature was only weakly significant.
## But if you look at the estimated effect size, the model shows little difference in the magnitudes
## of the trends with temperature and relative humidity.
m4<-glm(deadORalive ~ Species+Temp+Rel.Hum, family=quasibinomial, data=snails)
plot(m3)
summary(m4)
#call:
#glm(formula = deadORalive ~ Species * Temp * Rel.Hum, family = quasibinomial,
# data = snails)
#
#Deviance Residuals:
# Min 1Q Median 3Q Max
#-4.3587 -2.0465 -0.9864 1.5373 3.8610
#
#Coefficients:
# Estimate Std. Error t value Pr(>|t|)
#(Intercept) 4.742861 11.747775 0.404 0.687
#SpeciesB 0.429462 14.153376 0.030 0.976
#Temp -0.118988 0.704660 -0.169 0.866
#Rel.Hum -0.126446 0.178585 -0.708 0.481
#SpeciesB:Temp 0.070348 0.856805 0.082 0.935
#SpeciesB:Rel.Hum 0.013108 0.214611 0.061 0.951
#Temp:Rel.Hum 0.003071 0.010681 0.287 0.774
#SpeciesB:Temp:Rel.Hum -0.001318 0.012954 -0.102 0.919
#
#(Dispersion parameter for quasibinomial family taken to be 4.051934)
#
# Null deviance: 539.72 on 95 degrees of freedom
#Residual deviance: 416.25 on 88 degrees of freedom
#AIC: NA
## Nothing is significant! The combination of temperature and relative humidity cancel out.
## look at the two species separately
m5<-glm(spA$Deaths ~ spA$Temp+spA$Rel.Hum)
plot(m5)
summary(m5)
# spA$Rel.Hum -0.11566 0.05241 -2.207 0.0325 *
# just considering spA there is a weakly significant trend to lower mortality with higher humidity, but no significant effect of temperature.
m6<-glm(spB$Deaths ~ spB$Temp+spB$Rel.Hum)
plot(m6)
summary(m6)
# spB$Rel.Hum -0.2639 0.1036 -2.548 0.0143 *
## just considering spB there is a more significant trend to lower mortality with higher humidity, but again not with temperature.