R-alpha: nlme in R

Douglas Bates bates@stat.wisc.edu
Thu, 30 Oct 1997 21:01:52 -0600 (CST)


Tony Rossini sent me a copy of Jim's message to this list asking about 
nlme.  I was surprised to find that I had not subscribed to this
list.  I thought I did but apparently not.  I have now corrected that.

Development of the nlme library (the name is from "nonlinear
mixed-effects" but the library can also be used to fit general forms
of linear mixed-effects models) is a continuing research project for
Jose' Pinheiro and me.  Earlier this week Jose' spoke at the S-Users'
Conference about the design and development of the nlme 3.0 library.
The most visible change for nlme 3.0 is that it now can incorporate
nested random-effects terms.  In other words, it fits multilevel
models.  I'll check with Jose' on making the transparencies from that
talk available over the internet if people want to get more details.

Jim's question was "can it be ported to R?".  It is a lot of code.
Some of it would be easy to port.  Some of it would be extremely hard
to port.  "Extremely hard" means it would be easier to re-design and
re-write those parts from scratch.

The easy part is the linear mixed-effects code.  There is code in both 
S and in C but the C code is pretty straightforward.  The S code sets
up the model, formulates starting estimates for the parameters that
determine the variance-covariance matrices of the random effects,
calls some C code to do several EM iterations to refine the parameter
estimates then sets up the maximum likelihood estimation or REML
estimates as an ms() optimization.  I myself haven't tried to do this
in R but I think it is feasible to substitute nlm() for ms() at this
point.

There are a host of classes and methods that are defined to help with
this process and with examining the original data and the fitted
models.  *All* of these classes define their plot methods and other
graphical methods through trellis functions.  That means that either
the relevant trellis functions would have to be cloned or all the
graphical routines would have to be replaced or one would have to do
without graphics.  Some indication of the power of trellis for these
models is in the slides of Jose's presentation which should be
available soon at
     http://cm.bell-labs.com/cm/ms/departments/sia/project/nlme/

The nonlinear mixed-effects code will also be a problem.  It
alternates between two optimizations - one using ms() on a linear
mixed-effects problem and one using a special optimization routine for
a penalized nonlinear least squares problem.  The code for the second
one is intimately tied in with the S evaluation process and the frames
in S.  It would be necessary to re-write it from scratch.  Probably it
would be best to re-design it entirely.

More details available upon request.
-- 
Douglas Bates                            bates@stat.wisc.edu
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=