Reputation: 1063
I am running a lmer
model, with verbose = 2L
, as in the following simple example:
library(lme4)
myData <- data.frame(Y = rnorm(100),
Group = sample(LETTERS[1:2], 100, replace = TRUE))
LMER <- lmer(Y ~ (1 | Group), data = myData, verbose = 2L)
The verbose output looks like this:
npt = 3 , n = 1
rhobeg = 0.2 , rhoend = 2e-07
0.020: 6: 293.717;0.200000
0.0020: 8: 293.684;0.166601
0.00020: 12: 293.683;0.160047
2.0e-05: 14: 293.683;0.160260
2.0e-06: 15: 293.683;0.160260
2.0e-07: 17: 293.683;0.160254
At return
20: 293.68311: 0.160254
I would like to change the rhoend
parameter, with the idea of reducing the amount of time it takes to fit, presumably at the expense of getting less precise estimates.
How can I re-write my lmer()
call to alter the rhoend
parameter?
Upvotes: 2
Views: 237
Reputation: 226087
Like this:
See ?lmerControl
: you need to put the rhoend
setting inside a list called optCtrl
, to be passed to the optimizer.
LMER2 <- lmer(Y ~ (1 | Group), data = myData,
verbose = 2L, control=lmerControl(optCtrl=list(rhoend=1e-5)))
npt = 3 , n = 1
rhobeg = 0.03090896 , rhoend = 1e-05
start par. = 0.1545448 fn = 314.382
rho: 0.0031 eval: 3 fn: 314.382 par:0.154545
rho: 0.00031 eval: 5 fn: 314.380 par:0.165471
rho: 5.6e-05 eval: 7 fn: 314.380 par:0.164620
rho: 1.0e-05 eval: 9 fn: 314.380 par:0.164573
At return
eval: 10 fn: 314.37951 par: 0.164571
You could also consider using control=lmerControl(optimizer="nloptwrap")
in the latest (1.1-7) version of lme4
-- by default it uses a different implementation of the BOBYQA optimizer. See the examples in ?nloptwrap
to see that you can change the tolerances for changes in the parameters (xtol_abs
) or the response (ftol_abs
). The default tolerances for nloptwrap
are somewhat milder (= faster run times) than those for the default optimizer.
By the way, my answers are quite different from yours because we picked different random numbers. Best to use set.seed(101)
(or some other arbitrary integer of your choice) for reproducibility.
Upvotes: 4