[R] lme in R-2.0.0: Problem with lmeControl

Douglas Bates bates at stat.wisc.edu
Tue Nov 30 14:59:11 CET 2004


Pavel Khomski wrote:
> Hello!
> 
> One note/question hier about specification of control-parameters in the 
> lme(...,control=list(...)) function call:
> 
> i tried to specify tne number of iteration needed via 
> lme(....,control=list(maxIter=..., niterEM=...,msVerbose=TRUE))
> but every time i change the defualt values maxIter (e.g. maxIter=1, 
> niterEM=0)  on ones specified by me, the call returns all the iterations 
> needed until it's converged.
> and this is exactly the problem i will to get round.  (    e.g. in 
> example on p.81 of Pinheiro/Bates,2000: 
> fm1Rail.lme<-lme(...,control=list(maxIter=1,...))            )
> so i have tried with option msMaxIter=... and this works.
> 
> The other problem is, that i even can not see (in R !!!) the output from 
> iterations, despite the msVerbose=TRUE  specification and setting 
> options(verbose=TRUE) (The S-plus can do it but also ignoring the 
> maxIter=... specification)
> 
> Thank you for your hint
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

One difference between the S-PLUS and the R versions of lme is the 
optimizer that is used.  In S-PLUS the ms() function is used to optimize 
the log-likelihood.  In R the most reasonable choices are optim or nlm.

The version of lme in the current nlme package uses optim, which has a 
more sophisticated "verbose" option than just an on/off switch.  It has 
several levels of verbosity.  If we say that msVerbose corresponds to 
the lowest non-silent level then it only prints out intermediate results 
every five iterations and that example converges before 5 iterations.

 > library(nlme)
 > fm1Rail.lme <- lme(travel ~ 1, Rail, ~ 1|Rail,
+    control=list(niterEM=0,msVerbose=TRUE))
initial  value 67.893737
final  value 61.048859
converged
 >

If we were to set msVerbose=TRUE to give the highest level of verbosity 
you would be innundated with output.

The version of lme in the current lme4 package allows the optimizer to 
be chosen.  (The lme4 package cannot be loaded in the same session with 
the nlme package.  You must quit R and restart to be able to load the 
lme4 package).

 > library(lme4)
Loading required package: Matrix
Loading required package: latticeExtra
 > fm1Rail.lme <- lme(travel ~ 1, Rail, ~ 1 | Rail,
+   control = list(msVerbose = TRUE, optimizer = "nlm", niterEM = 0))
iteration = 0
Step:
[1] 0
Parameter:
[1] 0.1177830
Function Value
[1] 143.9911
Gradient:
[1] 7.849722

iteration = 1
Step:
[1] -7.849722
Parameter:
[1] -7.731939
Function Value
[1] 136.7956
Gradient:
[1] -4.880857

iteration = 2
Step:
[1] 3.009554
Parameter:
[1] -4.722385
Function Value
[1] 123.8982
Gradient:
[1] -2.879458

iteration = 3
Step:
[1] 0.9505343
Parameter:
[1] -3.771850
Function Value
[1] 122.207
Gradient:
[1] -0.4481287

iteration = 4
Step:
[1] 0.1751970
Parameter:
[1] -3.596653
Function Value
[1] 122.1802
Gradient:
[1] 0.1486718

iteration = 5
Step:
[1] -0.04364416
Parameter:
[1] -3.640298
Function Value
[1] 122.177
Gradient:
[1] -0.003887335

iteration = 6
Step:
[1] 0.00111209
Parameter:
[1] -3.639185
Function Value
[1] 122.177
Gradient:
[1] -3.100244e-05

iteration = 7
Parameter:
[1] -3.639177
Function Value
[1] 122.177
Gradient:
[1] 6.643475e-09

Relative gradient close to zero.
Current iterate is probably solution.

Those results do not match the output in our book because the version in 
  lme4 uses the deviance as the objective function.

(One of the difficulties of writing a book about a particular piece of 
software is that the software is likely to change much more rapidly than 
  the book.)

I show this with some trepidation because I am in the process of 
changing the optimization within lme yet again.  The development version 
ignores optimizer = 'nlm' because it phrases the problem as a 
constrained optimization problem and uses optim unconditionally.  The 
full level of verbosity of optim, which I occasionally use for 
development purposes, is very verbose

 > fm1Rail.lme <- lme1(travel ~ 1, Rail, ~ 1 | Rail,
+ control = list(msVerbose = TRUE, optimizer = "nlm", niterEM = 0))
N = 1, M = 5 machine precision = 2.22045e-16
L = 1e-10
X0 = 0.888889
U = inf
At X0, 0 variables are exactly at the bounds
At iterate     0  f=       143.99  |proj g|=       8.8309
Iteration     0

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -7.7985e+01  7.7985e+01
Distance to the stationary point =   1.0000e+00
Cauchy X =  9.71983

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 1
LINE SEARCH 0 times; norm of step = 1
X = 1.88889
G = -4.46694
Iteration     1

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -1.9954e+01  8.7077e+01
Distance to the stationary point =   2.2915e-01
Cauchy X =  2.91248

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 2
LINE SEARCH 0 times; norm of step = 1.02359
X = 2.91248
G = -2.81364
Iteration     2

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -7.9166e+00  1.2787e+01
Distance to the stationary point =   6.1912e-01
Cauchy X =  4.65446

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 3
LINE SEARCH 0 times; norm of step = 1.74198
X = 4.65446
G = -1.59578
Iteration     3

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -2.5465e+00  1.7803e+00
Distance to the stationary point =   1.4304e+00
Cauchy X =  6.937

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 4
LINE SEARCH 0 times; norm of step = 2.28253
X = 6.937
G = -0.919919
Iteration     4

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -8.4625e-01  2.5058e-01
Distance to the stationary point =   3.3772e+00
Cauchy X =  10.0438

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 5
LINE SEARCH 0 times; norm of step = 3.10678
X = 10.0438
G = -0.51183
Iteration     5

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -2.6197e-01  3.4411e-02
Distance to the stationary point =   7.6130e+00
Cauchy X =  13.9403

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 6
LINE SEARCH 0 times; norm of step = 3.89656
X = 13.9403
G = -0.279117
Iteration     6

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -7.7906e-02  4.6528e-03
Distance to the stationary point =   1.6744e+01
Cauchy X =  18.6139

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 7
LINE SEARCH 0 times; norm of step = 4.67355
X = 18.6139
G = -0.146855
Iteration     7

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -2.1566e-02  6.1033e-04
Distance to the stationary point =   3.5335e+01
Cauchy X =  23.8031

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 8
LINE SEARCH 0 times; norm of step = 5.18917
X = 23.8031
G = -0.0735916
Iteration     8

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -5.4157e-03  7.6462e-05
Distance to the stationary point =   7.0829e+01
Cauchy X =  29.0155

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 9
LINE SEARCH 0 times; norm of step = 5.21245
X = 29.0155
G = -0.0339817
Iteration     9

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -1.1548e-03  8.7751e-06
Distance to the stationary point =   1.3159e+02
Cauchy X =  33.4873

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 10
LINE SEARCH 0 times; norm of step = 4.4718
X = 33.4873
G = -0.0135712
Iteration    10

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -1.8418e-04  8.4064e-07
Distance to the stationary point =   2.1909e+02
Cauchy X =  36.4607

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 11
LINE SEARCH 0 times; norm of step = 2.97337
X = 36.4607
G = -0.0041181
Iteration    11

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -1.6959e-05  5.3916e-08
Distance to the stationary point =   3.1454e+02
Cauchy X =  37.756

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 12
LINE SEARCH 0 times; norm of step = 1.2953
X = 37.756
G = -0.000739049
Iteration    12

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -5.4619e-07  1.4249e-09
Distance to the stationary point =   3.8333e+02
Cauchy X =  38.0393

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 13
LINE SEARCH 0 times; norm of step = 0.283301
X = 38.0393
G = -5.08201e-05
Iteration    13

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -2.5827e-09  6.2742e-12
Distance to the stationary point =   4.1164e+02
Cauchy X =  38.0602

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 14
LINE SEARCH 0 times; norm of step = 0.0209195
X = 38.0602
G = -6.84527e-07
Iteration    14

---------------- CAUCHY entered-------------------

There are 0  breakpoints

GCP found in this segment
Piece      1 f1, f2 at start point -4.6858e-13  1.1230e-15
Distance to the stationary point =   4.1726e+02
Cauchy X =  38.0605

---------------- exit CAUCHY----------------------

1  variables are free at GCP on iteration 15
LINE SEARCH 0 times; norm of step = 0.000285625
X = 38.0605
G = -6.44794e-10

iterations 15
function evaluations 16
segments explored during Cauchy searches 15
BFGS updates skipped 0
active bounds at final generalized Cauchy point 0
norm of the final projected gradient 6.44794e-10
final function value 122.177

X = 38.0605
F = 122.177
final  value 122.177001
converged

The curious reader can try to work out what the current parameterization 
  is.  :-)  You win the prize if you can also explain why.




More information about the R-help mailing list