2

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?

Jon Wells
  • 23
  • 5

2 Answers2

2

There are actually only 16 parameters in the second question you reference, but some are called multiple times to represent interaction terms (though, whether that OP really wanted them to represent interactions, or intended for I(parameter^2), is unclear; if the latter, their code would have failed as there would have been too many unique parameters). So, even though there are many (~41) terms in that question, there are only 16 unique parameters.

As far as I can tell, @Kamil Bartoń has not updated dredge to accept more than 30 unique parameter calls yet.

Nigel Stackhouse
  • 481
  • 4
  • 20
  • I can't upvote but thank you for the explanation! I definitely thought it was ~41 predictors and that I was doing something wrong – Jon Wells Jan 16 '20 at 03:00
1

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)

Kamil Bartoń
  • 1,482
  • 9
  • 10
  • Thank you for the answer. I did some digging and was thinking of investing the time to copy this scientific paper that extends [R packages with 64 bit integer support](https://www.sciencedirect.com/science/article/pii/S0098300416307415). Basically making a compiled package using docall64 to support 64 bit integers when needed. Is that do-able with MuMIn or am I chasing a dream? – Jon Wells Jan 16 '20 at 02:58
  • @JonWells, I've tried to use `int64` package for this, but it is not compatible with R's native numerics so I gave up this idea. I suppose, coding the combinations with two integers is more worthwhile than adding C code to the package, but I dont expect to have time to play with it anytime soon. – Kamil Bartoń Jan 16 '20 at 16:20
  • Thanks for the response! The paper lists an "easy" way to create a 64bit shell of the existing package that is essentially empty and depends on the normal package/functions that are compiled with dotCall64 to cast between integer and double if I'm understanding correctly. I'm probably not technically skilled enough to accomplish the task on my own, but maybe I'll spend some time this semester and ask another question. Currently I've just eliminated columns by other means to get my model selection work done. Thank you for the great package! – Jon Wells Jan 18 '20 at 03:45