Hi,
I'm guessing you're referring to inla.mesh.2d meshes, with geo-located
observations?
The "amount of data at/near each mesh vertex/node can be obtained from
the mesh-to-observation A-matrix:
Aobs <- inla.spde.make.A(mesh, loc = locations)
data_per_node <- colSums(Aobs)
An observation exactly at a node will contribute 1 to the
corresponding data_per_node value.
An observation exactly at the centre of a triangle will contribute 1/3
to data_per_node for each of the three triangle vertices.
The total number of observations is sum(data_per_node).
Not sure if that's what you were looking for, but it provides a simple
way of counting "data per node".
Example that generates the attached figure:
library(INLA)
# For plotting:
library(inlabru)
library(ggplot2)
# A circular mesh:
bnd <- inla.nonconvex.hull(cbind(0,0), convex = 1.5)
mesh <- inla.mesh.2d(boundary = list(bnd), max.edge = 0.2)
# Random data locations, mapped to the mesh:
loc <- matrix(runif(1000) * 2 - 1, 500, 2)
Aobs <- inla.spde.make.A(mesh, loc)
data_per_node <- colSums(Aobs)
sum(data_per_node) # = nrow(loc)
# Plot the result
ggplot() +
gg(mesh) +
gg(SpatialPoints(loc))
ggplot() +
gg(mesh, colour = data_per_node) +
gg(mesh) +
gg(SpatialPoints(loc)) +
coord_equal() +
scale_fill_distiller("seq", "Blues", direction = +1,
breaks = seq(0, ceiling(max(data_per_node)), 1),
labels = seq(0, ceiling(max(data_per_node)), 1)) +
guides(fill = guide_colourbar(title = "Obs/Node"))
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/1c0834e7-742f-4a0b-966b-d41fb2b0b0bcn%40googlegroups.com.
--
Finn Lindgren
email:
finn.l...@gmail.com