# NOT RUN {
data(spider)
spiddat <- mvabund(spider$abund)
X <- as.matrix(spider$x)
## obtain residuals for Poisson regression of the spider data, and doing a qqplot:
glmP.spid <- manyglm(spiddat~X, family="poisson")
resP <- residuals(glmP.spid)
qqnorm(resP)
qqline(resP,col="red")
#clear departure from normality.
## try again using negative binomial regression:
glmNB.spid <- manyglm(spiddat~X, family="negative.binomial")
resNB <- residuals(glmNB.spid)
qqnorm(resNB)
qqline(resNB,col="red")
#that looks a lot more promising.
#note that you could construct a similar plot directly from the manyglm object using
plot(glmNB.spid, which=2)
# }
Run the code above in your browser using DataLab