# NOT RUN {
data(spider)
spider = list(abund=spider$abund, x = as.matrix(spider$x))
## To fit a log-linear model assuming counts are negative binomial, via manyglm:
spidNB <- manyany(abund~x,"manyglm",data=spider,family="negative.binomial")
logLik(spidNB) # a number of generic functions are applible to manyany objects
## To fit a glm with complementary log-log link to presence/absence data:
PAdat = pmin(as.matrix(spider$abund),1) #constructing presence/absence dataset
spidPA <- manyany(PAdat~x,"glm",data=spider,family=binomial("cloglog"))
plot(spidPA)
# There are some wild values in there for the Pardmont variable (residuals >5 or <-8).
#The Pardmont model didn't converge, coefficients are a bit crazy:
coef(spidPA)
# could try again using the glm2 package to fit the models, this fixes things up:
# }
# NOT RUN {
library(glm2)
# }
# NOT RUN {
spidPA2<-manyany(PAdat~x,"glm",data=spider,family=binomial("cloglog"),method="glm.fit2")
# }
# NOT RUN {
plot(spidPA2)
# }
# NOT RUN {
#looks much better.
## To simultaneously fit models to ordinal data using the ordinal package:
# }
# NOT RUN {
library(ordinal)
# }
# NOT RUN {
## First construct an ordinal dataset:
# }
# NOT RUN {
spidOrd = spider$abund
# }
# NOT RUN {
spidOrd[spider$abund>1 & spider$abund<=10]=2
# }
# NOT RUN {
spidOrd[spider$abund>10]=3
# }
# NOT RUN {
## Now fit a model using the clm function:
# }
# NOT RUN {
manyOrd=manyany(spidOrd~bare.sand+fallen.leaves,"clm",data=data.frame(spider$x))
# }
# NOT RUN {
plot(manyOrd)
# }
Run the code above in your browser using DataLab