Hi all,
I am new to INLA, but I have spent the last couple of weeks reading and playing with the various tutorials and the documentation. I feel that I have got to grips with the basics of the software. Thanks to you all for producing so much awesome documentation for this amazing package!
I would like to ask you experts and other users for some guidance and advice on my model. I apologise that this is such a long post! Please just respond to whatever you can/have time to.
My model is a species distribution model predicting the probability of occurrence of a species of insect as a function of various bioclimatic and demographic variables at a global scale. The data are presence/absence (~15,000 observations). The covariates are mostly raster data with a 5km*5km global resolution (WorldClim). The model has a binomial likelihood, some fixed effects covariates and a barrier.model spde spatial random effect:
y ~ b0 + BIOC_1 + BIOC_2 + ... + BIOC_p + f(s, model = barrier.spde) - 1
I have quite a few questions(!), but first I would like to ask for some advice on mesh building at a global scale.
To start with I took a shapefile of global coastlines. I simplified the polygons (using gSimplify from rgeos) and removed all the small islands below a specific area size. The aim of this was to try to avoid too complex a shape, so I can achieve nice uniform triangulation in my sampling domain. I then used these spatial polygons to define the inner boundary of the mesh, and used the observation points as initial vertices for the triangles. (Currently I am using decimal degrees, which I appreciate is inappropriate at a global scale, but I just wanted to get my head around the mesh building before implementing the spherical mesh).
## Domain boundary
bndry <- inla.sp2segment(
shape,
crs = crs(shape)
)
## Mesh
mesh <- inla.mesh.2d(
loc = coords.est,
boundary = bndry,
cutoff = max.edge.length/5,
max.edge = c(1, 5) * max.edge.length,
min.angle = 21
)
However, the observations have a pretty extreme non-random distribution. They are very clumped in certain areas. Using these locations as initial vertices seemed to be problematic, resulting in very high number of triangles and general bad mesh patterns (even when using a relatively high cutoff).
Next, after reading Finn's recommendation in this post, I decided to try a uniform inner triangulation (not using the observation points). This reduced the number of triangles and I can produce what I think seems like an OK mesh. After first running the model with a relatively coarse mesh to get an idea of the spatial range, the final mesh$n is ~10,000. (with an estimated spatial range of 10 degrees and max.edge = ~2 degrees).
Then I ran my model using int.strategy = "eb", strategy = "gaussian" and diagonal = 1000 to get some computationally cheap initial values to feed the proper model (using auto and simplified lapace) and every seems good, but then when I run the proper model, it seems to struggle. I get the 'stupid search' and my DIC is inf. This made me wonder that my mesh is too poor and it is causing numerical issues?
So, worried that my mesh is too complex. I read this post, and tried defining an arbitrary nonconvex hull as my boundary, rather than the shapefile itself.
## Non-convex hull domain boundary
nc.hull <- inla.nonconvex.hull(
coords.est,
convex = 3,
concave = 3,
resolution = 150)
## Mesh.nc
mesh.nc <- inla.mesh.2d(
boundary = nc.hull,
cutoff = max.edge.length/5, # make max.edge/5 for full resolution
max.edge = c(1, 3) * max.edge.length,
# offset = 1, #c(max.edge.length, outer.boundary),
min.angle = 20
)
This results in a mesh$n of ~5000 and a much more uniform 'good' look. But I am worried that altering the geographic structure makes the barrier method somewhat pointless?
I would really appreciate some guidance or insight on the best way to approach this mesh building. I would like to be able to find the good trade-off between mesh complexity and computational expense! Apologies if I have made any glaring errors or oversights...
and apologies for rambling...
Thanks for taking the time to read this far :)
Cheers,
Mike