# [R-sig-ME] extracting gradient and hessian matrix from lme4

Joshua Wiley jwiley.psych at gmail.com
Sun Mar 18 05:35:35 CET 2012

Hi,

I am trying to use a multivariate mixed effects linear model to
examine mediation.  This works fine.  The final step is to compute the
indirect effect and its standard error.  The indirect effect is easy
(product of coefficients plus their covariance).  For the standard
error, I need the gradient (D) and the hessian (H):
the variance is then:

D'\Sigma(\theta)D + \frac{1}{2}Tr{(\mathbf{H}\boldsymbol{\Sigma}(\theta))^{2}}

This is all given in the Appendix of
http://www.unc.edu/~dbauer/manuscripts/bauer-preacher-gil-PM-2006.pdf

Is there a way to get this out of a mer class object?  Looking at
class?mer, the appropriate bits of vcov give me $\Sigma(\theta)$.  @V
seems like it would give me the gradient but is null for a basic lmer
model.

Thanks,

Josh

--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/