Search code examples
rmumin

Error in MuMin pdredge() when using more than 30 predictor variables


I've run into the following error that only occurs when I pass a model with more than 30 predictors to pdredge():

Error in sprintf(gettext(fmt, domain = domain), ...) : invalid format '%d'; use format %f, %e, %g or %a for numeric objects

I'm on a windows machine running Microsoft R Open through RStudio:

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
RStudio Version 1.0.153
MuMIn_1.43.6

Reproducible example:

library(MuMIn)
library(parallel)

#Random data: X1 as response, X2-X31 (30) predictors
var.30 <- data.frame(replicate(31,sample(0:100,75,rep=TRUE)))

#Random data: X1 as response, X2-X32 (31) predictors
var.31 <- data.frame(replicate(32,sample(0:100,75,rep=TRUE)))

#prepare cluster for pdredge
clust <- try(makeCluster(detectCores()-1))

#working model (30 or less predictors)
mod <- lm(X1 ~ ., data=var.30, na.action = "na.fail")
sub.dredge <- pdredge(mod, cluster=clust, eval=FALSE)

#Non-working model (31 or more predictors)
mod <- lm(X1 ~ ., data=var.31, na.action = "na.fail")
sub.dredge <- pdredge(mod, cluster=clust, eval=FALSE)

I know in 2016 that this was an issue with integer bit restrictions. However, from this question and the comments it received, I was under the impression that the issue was resolved and the maximum changed?


Solution

  • The 31 terms limit in dredge is pretty much ultimate. It will not be extended unless R implements native support for 64-bit integers.

    (Also, update your MuMIn - this 'sprintf' error has been fixed some time ago)