1

I was using glm with dredge in MuMIn package. But now since my data is large I am using bigglm from biglm package. Now how do I do model selection now since dredge does not work with bigglm? Is there another package I can use to achieve this?

On applying the dredge on bigglm I am receiving the following error:

Error in nobs.default(global.model) : no 'nobs' method is available

Community
  • 1
  • 1
user13892
  • 267
  • 4
  • 12

1 Answers1

0

dredge relies on availability of logLik method for the the given model class. big[g]lm object does not provide such value, and there seems to be a long known bug in the AIC method for big[g]lm-class that makes it impossible to calculate LL from it (it uses deviance rather than LL to calculate AIC, so AIC-values are not comparable to other model types, see here: AIC different between biglm and lm).

You could try adding the missing methods (using deviance instead of LL, which may be slippery):

# incorrect if any prior weights are 0 
nobs.biglm <- function (object, ...) object$n

logLik.bigglm <- function(object, ...) {
    dev <- deviance(object, ...)
    df <- object$n - object$df.resid
    structure(dev, df = df, nobs = object$n)
}

coefTable.biglm <- function (model, data, ...) {
    ct <- summary(model)$mat[, c(1L,4L,5L), drop = FALSE]
    .makeCoefTable(ct[, 1L], se = ct[, 2L], df = model$df.resid, coefNames = rownames(ct))  
}
environment(coefTable.biglm) <- asNamespace("MuMIn")

#from example(bigglm)

fm <- bigglm(log(Volume)~log(Girth)+log(Height),data=trees, chunksize=10, sandwich=TRUE)
dredge(fm, rank = AIC)
Kamil Bartoń
  • 1,482
  • 9
  • 10