getting Hessian when specifying random effects in pcount()

20 views
Skip to first unread message

Marc Kery

unread,
Jul 8, 2024, 10:32:24 AM (11 days ago) Jul 8
to unmarked, ahavard....@gmail.com

Dear all,

 

I need the variance-covariance matrix from the Hessian matrix in a model fit with pcount(). Normally, unmarked issues the Hessian in the slot xxx@opt$hessian, where xxx is the fitted model object from pcount.

 

However, we’re specifying random observer effects in detection probability. In this case, unmarked uses program TMB under the hood, and then there is no Hessian in $opt. Is there a way to get the Hessian in this case as well ?

 

Thanks and best regards  -- Marc

Ken Kellner

unread,
Jul 8, 2024, 11:10:55 AM (11 days ago) Jul 8
to unmarked
Hi Marc,

You should still be able to get the vcov matrix with vcov(). By default it just returns the fixed effects part, but you can also do vcov(..., fixedOnly = FALSE) to get the full joint variance-covariance matrix with all the random effects included (but not the random effect variances). If you want to do it manually you can access the TMB object in the @TMB slot and use something like

sdr <- TMB::sdreport(fit@TMB, getJointPrecision=TRUE)
v <- solve(sdr$jointPrecision)

It is not possible to get the Hessian specifically for your model, as far as I know, because of TMB limitations

fm@TMB$he()

returns

Error in fm@TMB$he() : Hessian not yet implemented for models with random effects.

Ken
Reply all
Reply to author
Forward
0 new messages