[R-sig-ME] Entry point for lme4a

Douglas Bates bates at stat.wisc.edu
Mon Oct 4 19:32:59 CEST 2010


On Mon, Oct 4, 2010 at 11:50 AM, Koala <skorsky12 at gmail.com> wrote:
> I am trying to pinpoint the entry point into C++ functions for lme4a. This
> function in external.cpp

> RCPP_FUNCTION_6(NumericVector, merDeviance, S4 xp, NumericVector theta,
>                NumericVector beta, NumericVector u0, int verb, int alg) {

> seemed to be it, but it is being called multiple times.

Yes, that is the C++ function that evaluates the deviance.  It is
called repeatedly during the optimization of the deviance or REML
critterion.

> What is the
> corresponding C function to lmer() call in R? I am trying to call lme4a from an
> outside C++ function that I need to integrate.

I have tried to explain that there is no one C function the
corresponds to lmer.  If you look at the R code for lmer you will see
that a large amount of the code is written in the R language itself
and only the very core of the evaluation of the objective function is
written in the compiled language.  Expecting that there will be one C
function that you call and it "does lmer" for you is naive.  The lme4a
package depends strongly on the Matrix package, which, in turn,
depends on the CHOLMOD and AMD C libraries, and the MatrixModels
package and the Rcpp package and many, many facilities in base R.

If you have a very simple model and you need to implement the
calculations in C then I would suggest starting from the equations
rather than trying to find some magic C code that isn't there.  I'm
still at a loss to understand why you need to reimplement these
calculations in C.  I have been contacted in the past by software
vendors (Cytel) who thought that they could easily modify the lme4a
package to include such capabilities in proprietary software and this
is beginning to sound like that.

The lmer function is an R function that relies strongly on the
capabilities in base R and many R packages.  If you want to recreate
it from scratch in C you have a lot of work to do, much more than
simply discovering which C entry point to call.




More information about the R-sig-mixed-models mailing list