[Rd] Bootstrapping stepAIC() with glm.nb()
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Fri Feb 23 13:20:24 CET 2007
Dear all,
I would like to Boostrap the stepAIC() procedure from package MASS for
variety of model objects, i.e.,
fn <- function(object, data, B = 2){
n <- nrow(data)
res <- vector(mode = "list", length = B)
index <- sample(n, n * B, replace = TRUE)
dim(index) <- c(n, B)
for (i in 1:B) {
up.obj <- update(object, data = data[index[, i], ])
res[[i]] <- stepAIC(up.obj, trace = FALSE)
}
res
}
####################
library(MASS)
# 'glm' objects
x1 <- runif(100, -4, 4)
x2 <- runif(100, -4, 4)
y <- 1 + 2 * x1 + rnorm(100, sd = 3)
dat <- data.frame(y, x1, x2)
glmFit <- glm(y ~ x1 + x2, data = dat)
fn(glmFit, data = dat)
# 'aov' objects
quine.hi <- aov(log(Days + 2.5) ~ .^4, quine)
fn(quine.hi, data = quine)
However, for "negbin" objects returned by glm.nb() the following
problem occurs:
quine.nb <- glm.nb(Days ~ .^4, data = quine)
fn(quine.nb, data = quine)
Any hints to overcome this are greatly appreciated.
Thanks in advance,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-devel
mailing list