Message-ID: <62fc69c1-698f-2b94-aea4-4b5ec2e10a6f@gmail.com>
Date: 2022-09-24T22:58:41Z
From: Ben Bolker
Subject: Find Hessian in MixCat and glmmTMB packages
In-Reply-To: <BL0PR04MB4563778B131E342C305020ACB9509@BL0PR04MB4563.namprd04.prod.outlook.com>
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 at 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.