[R-sig-ME] Subject-wise log-likelihood gradient and hessian

Ben Bolker bbolker at gmail.com
Mon Oct 1 00:47:02 CEST 2012

Rubem Kaipper Ceratti <rubem_ceratti at ...> writes:

> Hi all,
> I'd like to know if it's possible to extract the subject-wise 
> gradient and hessian of the marginal
> log-likelihood from a 'mer' object. 

  Can you explain in slightly greater detail?  What are the
parameters you're taking the gradient and hessian with respect
to -- sounds like the fixed-effect parameters (beta)?  How do
you define "subject-wise"?  The marginal likelihood is only
defined with respect to the full data set, isn't it?

> Using the 'cbpp' dataset as an example:
> library(lme4)
> (m1 <- glmer(size ~ period+(1|herd), cbpp, poisson))

> Since apparently there's no way to get what I need directly, I've
> thought about splitting the data frame by 'herd', updating m1 on
> each subset and then calling numDeriv::grad() and
> numDeriv::hessian() on the deviance function of each updated object
> at the estimates from m1, but I couldn't get this approach to work.
> Any input is appreciated. 

  I assume you're already using the development version, as
the deviance function is only available in the development version?

>  Thanks (and sorry for the broken english),

 English seems fine -- it's the technical description that's
eluding me a bit.

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