NBRAYKO / LMERConvenienceFunctions

:exclamation: This is a read-only mirror of the CRAN R package repository. LMERConvenienceFunctions — Model Selection and Post-hoc Analysis for (G)LMER Models
0 stars 0 forks source link

Backfitting does not take non-default glmer optimizer #1

Open NBRAYKO opened 8 years ago

NBRAYKO commented 8 years ago

From the example:

library(lme4)
library(LCFdata)
data(eeg)

# restrict to electrode Fz and 80--180 ms window
eeg <- eeg[eeg$Time >= 80 & eeg$Time <= 180, ]
eeg <- eeg[, c("Subject", "Item", "Time", "Fz",
               "FreqB", "LengthB", "WMC")]
# mean center FreqB
eeg$FreqBc <- eeg$FreqB - mean(eeg$FreqB)
# split FreqBc into 3 categories. Doesn't make sense,
# but it's merely for example
eeg$FreqBdc <- "high"
eeg$FreqBdc[eeg$FreqBc<=quantile(eeg$FreqBc)[3]] <- "mid"
eeg$FreqBdc[eeg$FreqBc<=quantile(eeg$FreqBc)[2]] <- "low"
eeg$FreqBdc <- as.factor(eeg$FreqBdc)
eeg$FreqBdc <- relevel(eeg$FreqBdc, "low")

eeg$LengthBc <- eeg$LengthB - mean(eeg$LengthB)
# mean center WMC
eeg$WMCc <- eeg$WMC - mean(eeg$WMC)

Fitting a glmer model using this code, and the update() statement in the function does not capture the arguments passed on to control. Setting options globally with options(glmerControl(list(optCtrl=list(maxfun=2e4)))) also fails

m4_test <- glmer(FreqBdc ~ (Fz + LengthBc + WMCc)^2 + (1 | Subject),
                 control = glmerControl(
                   optCtrl=list(maxfun=2e4),# increase the number of max fun evaluations, help to converge
                   optimizer = "nloptwrap" #using the nloptwrap optimizer makes it up to 50% faster! won't do backwards selection 
                   ),

                 family = "binomial", data = eeg)

m5_test <- bfFixefLMER_t.fnc(model = m4_test, method = "AIC",log.file = FALSE)

error:

Error in (function (optimizer = "bobyqa", restart_edge = TRUE, boundary.tol = 1e-05,  : 
  unused arguments (tolPwrss = 1e-07, compDev = TRUE, nAGQ0initStep = TRUE, checkControl = list(check.nobs.vs.rankZ = "ignore", check.nobs.vs.nlev = "stop", check.nlev.gtreq.5 = "ignore", check.nlev.gtr.1 = "stop", check.nobs.vs.nRE = "stop", check.rankX = "message+drop.cols", check.scaleX = "warning", check.formula.LHS = "stop", check.response.not.const = "stop"), checkConv = list(check.conv.grad = list(action = "warning", tol = 0.001, relTol = NULL), check.conv.singular = list(action = "ignore", tol = 1e-04), 
NBRAYKO commented 8 years ago

Source of problem: function tries to refit a glmer model as an lmer where the response variable is drawn from random normal distribution. All this in order to get an ANOVA table... Not sure why, pretty sure it is just a way to create an anova table that lists all coefficients. Need to compute this temp.lmer model as fast as possible