Hi, Ben, thanks for your response. See below.



>  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)?  

Yes, both gradient and hessian would be taken with respect to the fixed effects parameters.

> How do you define "subject-wise"?

Assuming I have a single grouping factor, then "subject-wise" would be "by each level of the grouping factor".

> The marginal likelihood is only defined with respect to the full data set, isn't it?

Correct me if I'm wrong, but isn't the marginal log-likelihood of the model a sum of the contribution from each grouping level? E.g., if I have $N$ subjects ($i = 1,..., N$), then
 $l(y | \beta, \sigma) = \sum^N_{i = 1} l_i(y_i | \beta, \sigma)$, where $l_i(y_i | \beta, \sigma) = \int^\infty_{-\infty} f(y_i | \beta, u_i) g(u_i | \sigma) du_i$. What I'm interested in is the first and second order derivatives of $l_i$ with respect to $\beta$.

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


No, I'm using version 0.999999-0 from CRAN. I was bluntly trying to make it work with .Call('mer_update_dev',...).

Thanks,
Rubem



________________________________
 De: Ben Bolker <bbolker@gmail.com>
Para: r-sig-mixed-models@r-project.org 
Enviadas: Domingo, 30 de Setembro de 2012 19:47
Assunto: Re: [R-sig-ME] Subject-wise log-likelihood gradient and hessian

Rubem Kaipper Ceratti <rubem_ceratti@...> 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.

_______________________________________________
R-sig-mixed-models@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
	[[alternative HTML version deleted]]

