Specify a continuous Matern spatial field using externally-provided FEM matrices. Use this with meshes from fmesher, rSPDE, or any other source.
Arguments
- C
Mass matrix (n_mesh x n_mesh sparse matrix, e.g. from
fmesher::fm_fem()$c0).- G
Stiffness matrix (n_mesh x n_mesh sparse matrix, e.g. from
fmesher::fm_fem()$g1).- A
Projection matrix (n_obs x n_mesh sparse matrix, e.g. from
fmesher::fm_basis()).- nu
Matern smoothness parameter. A positive number; integer values give the exact FEM construction, fractional values the BRASIL rational SPDE approximation (supported by
fit_spde();). Default 1.- prior_range
PC prior on the spatial range,
c(U, alpha)with P(range < U) = alpha.NULL(the default) anchors it oncoordsasspatial_spde()does, and needs them.- prior_sigma
PC prior on the marginal standard deviation,
c(U, alpha)with P(sigma > U) = alpha.NULL(the default) isc(3, 0.01).- coords
Observation coordinates (an
n_obs x 2matrix), read only to anchor the default range prior. Not needed whenprior_rangeis given.
Examples
# FEM matrices of a 6-node 1-D chain mesh, observed at the nodes:
n <- 6L
C <- Matrix::Diagonal(n)
G <- Matrix::bandSparse(n, k = c(-1, 0, 1),
diagonals = list(rep(-1, n - 1), c(1, rep(2, n - 2), 1),
rep(-1, n - 1)))
A <- Matrix::Diagonal(n)
sp <- spatial_spde_custom(C, G, A, prior_range = c(1, 0.5),
prior_sigma = c(1, 0.01))
sp$type