[R-sig-ME] Find Hessian in MixCat and glmmTMB packages
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Sun Sep 25 00:58:41 CEST 2022
From ?npmlt,
## CVmat: the inverse of the observed information matrix of the model.
rcond(solve(a$CVmat))
(this is the inverse condition number)
For glmmTMB: the Hessian isn't stored in the object, here is one way
to compute it:
hessian.glmmTMB <- function(fit) {
obj <- fit$obj
ee <- obj$env
pp <- ee$last.par.best
if (!is.null(r <- ee$random)) {
pp <- pp[-r]
}
h <- numDeriv::jacobian(obj$gr, pp)
return(h)
}
rcond(hessian.glmmTMB(m1))
On 2022-09-24 12:25 p.m., Sun, John wrote:
> Dear All,
>
> I am writing to ask how to find the hessian from these fitted objects to calculate the condition number of the hessian to diagnose loss of precision.
> Please let me know if you know any information.
>
> library(mixcat)
> data(schizo)
> attach(schizo)
> a<-npmlt(y~trt*sqrt(wk),formula.npo=~trt,random=~1+trt,id=id,k=2,EB=FALSE)
>
> library(glmmTMB)
> (m1 <- glmmTMB(count ~ mined + (1|site),
> zi=~mined,
> family=poisson, data=Salamanders))
>
> I cannot find how to find the hessian from these fitted objects.
>
> Best regards,
> John
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
> E-mail is sent at my convenience; I don't expect replies outside of
working hours.
More information about the R-sig-mixed-models
mailing list