Gamma Hurdle Model Problems

36 views
Skip to first unread message

Sylvan Benaksas

unread,
Nov 22, 2021, 6:20:56 AM11/22/21
to R-inla discussion group
Hello Everyone,

I am trying to run a gamma hurdle model in r-inla. I am running the binomial and gamma models separately, the binomial model seems to run fine, with a 2 minute run time, however the gamma model seems to run into an error. The model runs but takes nearly 2 hours and with outputs that do not make sense (fitted values, fixed effect coefficients). This argument is repeated over and over in the verbose argument:

file: smtp-taucs.c  1f6a39183ef43d8ef33f10ff3f04fd13f8432758 - Mon Feb 22 21:27:50 2021 +0300
Function: GMRFLib_build_sparse_matrix_TAUCS(), Line: 759, Thread: 0
Variable evaluates to NAN or INF. idx=(8,8). I will try to fix it...


I also notice that the  effective parameters is near 0 and I think maybe the model cannot be formulated for some reason?

Expected effective number of parameters: 9.050(0.000),  eqv.#replicates: 62.871
DIC:
Mean of Deviance ................. -7120.93
Deviance at Mean ................. -7120.93
Effective number of parameters ... 0.000238915
DIC .............................. -7120.93

I have attached example code and data if anyone can offer any advice it would be much appreciated,

Best wishes,
Sylvan
ns sandeels env biomass.csv
separated gamma hudle model.R

Elias T. Krainski

unread,
Nov 22, 2021, 7:46:06 AM11/22/21
to R-inla discussion group
The mesh is not adequate. You need to have max.edge smaller than the range. Once you have a proper mesh, the results shouldn't rely on small changes to it. 

--
You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/d9216c34-4cef-4244-9fb6-f4cebeb4d07dn%40googlegroups.com.

Sylvan Benaksas

unread,
Nov 22, 2021, 11:39:01 AM11/22/21
to R-inla discussion group
Hi Elias,

Thanks for getting back to me and offering the advice. I have redefined my mesh, I had changed the setting to create a small mesh as I was having memory issues, what argument in mesh specification are you referring to when you say range? here is my updated mesh specification

MaxEdge <-3 00
bound.outer = diff(range(dat$Xkm))/3
bnd <- inla.nonconvex.hull(loc,convex= -0.05)
mesh <- inla.mesh.2d(boundary = bnd, max.edge = c(1, 5) * MaxEdge, 
                     cutoff = MaxEdge / 5,
                     offset = c(MaxEdge, bound.outer))

Many thanks,
Sylvan

Sylvan Benaksas

unread,
Nov 23, 2021, 5:25:53 AM11/23/21
to R-inla discussion group
I seem to have fixed the problem by accident, the recommendation from Elias helped but the major problem was I had incorrectly specified my pc priors in my spde object, the range was far too low and sigma too high. The gamma model now runs in 2 minutes, with no NaN errors and with great outputs!

Cheers,
Sylvan
Reply all
Reply to author
Forward
0 new messages