Hi everyone,
I am trying to build a spatial model accounting for barriers. However, I do not fully understand the pipeline (workflow) we are supposed to follow. I have only found three available tutorials on implementing a barrier model, but I am confused about why they differ. The tutorials are:
https://eliaskrainski.github.io/INLAspacetime/articles/web/barrierExample.html#abstract
https://haakonbakkagit.github.io/btopic128.html#6_Implementation_(Models) (obsolete)
https://becarioprecario.bitbucket.io/spde-gitbook/ch-nonstationarity.html#ch:barrier
What I don’t understand is how they create the s.index after defining the SPDE. In a model without barriers, the steps are:
A) Define the mesh
B) Define the SPDE (inla.spde2.pcmatern) and create the s-index (inla.spde.make.index)
However, in the barrier model the workflow seems different. In the tutorials, they do not define a s.index. The workflow is:
A) Define the mesh accounting for the boundary (water polygon)
B) Identify the triangles inside the polygon (fmesher::fm_contains)
C) Create a SPDE with the barrier (inla.barrier.pcmatern) – here no s.index is define
For example:
water.tri <- fmesher::fm_contains(
ocean_poly,
y = mesh,
type = "centroid"
)
water.tri.idx <- water.tri[[1]]
length(water.tri.idx)
num.tri <- nrow(mesh$graph$tv)
barrier.tri <- setdiff(1:num.tri, water.tri.idx)
poly.barrier <- inla.barrier.polygon(
mesh,
barrier.triangles = barrier.tri
)
spde_barrier <- inla.barrier.pcmatern(
mesh = mesh,
barrier.triangles = barrier.tri,
prior.range = c(100000, 0.5),
prior.sigma = c(1, 0.01)
)
D) Build the projection matrix A
E) Define the stack – where in the previous method you have s.index, here the code uses s = 1:mesh$n. For example:
stack.1 <- inla.stack(
data = list(y = df$presence),
A = list(A, 1),
effects = list(
s= 1:mesh$n,
df %>% transmute(
intercept = 1,
Depth_s, BotTemp_s, year_f, mean_len_s
)
),
tag = "fit"
)
F) Define the formula and fit the model with INLA
The problem is that when I apply this workflow, the spatial effect does not seem to be used. My question is: do I need to define SPDE indices (s.index) in a barrier model? If not, why does INLA not seem to include the spatial effect?
Thank you so much for the information and help.
Kind regards,
Lola R
--
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, visit https://groups.google.com/d/msgid/r-inla-discussion-group/ca27513e-678a-4629-aeab-46ab1179b8afn%40googlegroups.com.