lme4/lme4 — pull request #245 by ggrothendieck (2014-09-30 15:17:17+00:00)
Title: better starting values for 1|f lmer models

This commit generates better lmer starting values if the only random effects terms are of the form `(1|f)`. There may be any number of such terms.

Based on the script at the end, on both the InstEval and Rail datasets this results in 50% fewer iterations and this results in about 50% less time for InstEval and 25% less time for Rail. The old version of lme4 used ones as the starting values for `theta` so to compare we set `start` to ones for runs intended to emulate this old behavior.

The procedure is as follows. If `1|f` is the ith random effects term then we estimate its variance as:
```
v[i] <- var(ave(y, f))
```
We then estimate the residual variance as:
```
v.e <- var(y) - sum(v)
```
and finally `theta` (which is the input to the optimization and represents the ratio of the standard deviation to the residual standard deviation) is estimated as:
```
theta <- sqrt(v/v.e)
```

R test script:
```
library(lme4)
trace(lme4:::optwrap, quote(print(par))) # display starting values
ctrl <- lmerControl(calc.derivs = FALSE, optCtrl = list(iprint = 1))

system.time(fm.ie1 <- lmer(y ~ service * dept + (1|s) + (1|d), InstEval, start = c(1, 1), control = ctrl))
system.time(fm.ie2 <- lmer(y ~ service * dept + (1|s) + (1|d), InstEval, control = ctrl))
getME(fm.ie2, "theta")

data(Rail, package = "nlme")
system.time(fm.rail1 <- lmer(travel ~ (1|Rail), Rail, start = 1, control = ctrl))
system.time(fm.rail2 <- lmer(travel ~ (1|Rail), Rail, control = ctrl))
getME(fm.rail2, "theta")
```