I fitted a mixed model of the following form:
global.mod <- lmer(log(y) ~
x1 + x2 + x3 + x4 + x5 + (1 + x1|a/b),
REML = FALSE, data = lmerDat,
na.action = 'na.fail', control = lmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e4)))
I then use predge
to create combinations of model below which works fine.
require(parallel) || require(snow)
clusterType <- if(length(find.package("snow", quiet = TRUE))) "SOCK" else "PSOCK"
clust <- try(makeCluster(getOption("cl.cores", 4), type = clusterType))
clusterEvalQ(clust, library(lme4))
clusterExport(clust, "lmerDat")
model.set <- pdredge(global.mod, clust,
m.lim = c(2, NA), rank = AIC, extra = "adjR^2", trace = 2)
I then tried to specify my models in a slightly different format as below:
PredictorVariables <- names(lmerDat)[c(5:9)] # this is x1 till x5
fixed.part <- paste("log(y) ~", paste(PredictorVariables, collapse=" + "))
random.part <- paste('(1 + x1|a/b)')
Formula <- formula(paste(fixed.part, random.part, sep = " + "))
global.mod <- lmer(Formula, data = lmerDat, na.action = 'na.fail', control =
lmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e4)), REML = FALSE)
require(parallel) || require(snow)
clusterType <- if(length(find.package("snow", quiet = TRUE))) "SOCK" else "PSOCK"
clust <- try(makeCluster(getOption("cl.cores", 4), type = clusterType))
clusterEvalQ(clust, library(lme4))
clusterExport(clust, "lmerDat")
model.set <- pdredge(global.mod, clust,
m.lim = c(2, NA), rank = AIC, extra = "adjR^2", trace = 2)
However, this gives me the follow error
Error in sprintf(gettext(fmt, domain = domain), ...) :
invalid format '%d'; use format %f, %e, %g or %a for numeric objects
Unfortunately the latter is how I want to do the model specification since apriori I do not know what will be the names of the predictors in names(lmerDat)[c(5:9)]
. Could anyone help me understand the error and how to resolve it?
EDIT
my traceback output is as follows (please note that this is on my original data instead of the dummy data above).
7: sprintf(gettext(fmt, domain = domain), ...)
6: gettextf(Message, ..., domain = domain)
5: structure(list(message = as.character(message), call = call),
class = class)
4: simpleError(gettextf(Message, ..., domain = domain), Call)
3: stop(simpleError(gettextf(Message, ..., domain = domain), Call))
2: cry(, "number of non-fixed predictors [%d] exceeds the allowed maximum of %d (with %d variants)",
nov, novMax, nVariants)
1: pdredge(global.mod, clust)