INLA Mesh Assessment

117 views
Skip to first unread message

Brian

unread,
Apr 19, 2024, 6:52:01 AM4/19/24
to R-inla discussion group
Hello Finn,

I have created my mesh using the following code

```
mesh.loc <- SpatialPoints(as.matrix(coords_mesh))
mesh <- inla.mesh.2d(loc=mesh.loc,
                     boundary = bdry,
                     max.edge=c(0.01, 1.42),
                     min.angle=c(30, 21),
                     max.n=c(48000, 16000), ## Safeguard against large meshes.
                     max.n.strict=c(128000, 128000), ## Don't build a huge mesh!
                     cutoff=5e-04, ## Filter away adjacent points.
                     offset=c(2.78, 3)) ## Offset for extra boundaries, if needed.

```
Then afterwards, I have assessed the mesh as follows;

```
inla.mesh.assessment(mesh, spatial.range = 3)
``
The results are as follows;


```
> inla.mesh.assessment(mesh, spatial.range = 3)
class       : SpatialPointsDataFrame
features    : 250000
extent      : 30.90961, 44.92622, -7.720139, 8.061166  (xmin, xmax, ymin, ymax)
crs         : NA
variables   : 3
names       :                sd,            sd.dev,            edge.len
min values  : 0.888000581154969, 0.894983000912329, 0.00105070743723504
max values  :  1.69762166787744,  1.31240440047992,    1.25560412671986 
```

How well does the mesh fit my data, and from the above results, what do I use to assess how well my mesh is.


Thank you

Finn Lindgren

unread,
Apr 19, 2024, 7:24:57 AM4/19/24
to Brian, R-inla discussion group
Hi,

following the inla.mesh.assessment() documentation example, I'd do

# replace with your mesh construction:
bnd <- inla.mesh.segment(cbind(
c(0, 10, 10, 0, 0),
c(0, 0, 10, 10, 0)
), bnd = TRUE)
mesh <- inla.mesh.2d(boundary = bnd, max.edge = 1)

# Replace the spatial.range value with one relevant for your problem:
out <- inla.mesh.assessment(mesh, spatial.range = 3, alpha = 2)

# Plot the sd.dev variable of the output:
library(ggplot2)
ggplot()+geom_sf(data=sf::st_as_sf(out),aes(color=sd.dev))

In this mesh, the edges are around 0.7 units long, compared with the
testing range of 3, and the sd.dev (an estimate of the ratio between
the pointwise std.dev based on the mesh, against the std.dev. from a
high resolution mesh) varies between ca 0.95 and 1.3.
Values around 1 indicate a close approximation of the high resolution
model, whereas smaller/larger values indicate a potentially too coarse
mesh, leading to higher approximation error.
In the plot, you can see that the large deviations are at the mesh
nodes, and slightly higher along the boundary.

With the same mesh but spatial.range=6, the largest deviation ratio is
now only 1.12, so the approximation of the spde model with that
correlation range is pretty good, and clearly better than for range =
3.

Finn
> --
> 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/1bcce3c1-5492-49d9-9679-387bcc4bd723n%40googlegroups.com.



--
Finn Lindgren
email: finn.l...@gmail.com

Brian

unread,
Apr 19, 2024, 11:11:57 AM4/19/24
to R-inla discussion group
Thank you.
Reply all
Reply to author
Forward
0 new messages