## Starting from a "betabinom" model
## Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language.
## Wadsworth & Brooks/Cole. (has iris3 as iris.)
## Prepare the data
library(aod)
data(iris)
############ Beta Binomial model
if (FALSE) {
n <- round(runif(dim(iris)[1],1,50))
y <- round(runif(length(n), 1,n))
data <- cbind(iris,y,n)
fullModel <- betabin(cbind(y, n - y) ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species,
data = data)
reducedModel <- Step_glimML(fullModel)
summary(reducedModel)
}
############ Negative Binomial model
if (FALSE) {
data <- iris
data$Sepal.Length <- round(Sepal.length + runif(dim(data)[1],0,1) * 100)
fullModel <- negbin(Sepal.Length ~ Sepal.Width * Petal.Length + Petal.Width, ~ Species,
data = data)
reducedModel <-Step_glimML(fullModel)
summary(reducedModel)
}
Run the code above in your browser using DataLab