fm_gmrf | R Documentation |
fm_matern_precision(x, alpha, rho, sigma)
fm_matern_sample(x, alpha = 2, rho, sigma, n = 1, loc = NULL)
fm_covariance(Q, A1 = NULL, A2 = NULL, partial = FALSE)
fm_sample(n, Q, mu = 0, constr = NULL)
fm_matern_sample()
returns a matrix, where each column is a sampled
field. If loc
is NULL
, the fm_dof(mesh)
basis weights are given.
Otherwise, the evaluated field at the nrow(loc)
locations loc
are given
(from version 0.1.4.9001
)
fm_matern_precision()
: Construct the (sparse) precision matrix for the basis weights for
Whittle-Matérn SPDE models. The boundary behaviour is determined by the
provided mesh function space.
fm_matern_sample()
: Simulate a Matérn field given a mesh and
covariance function parameters, and optionally evaluate at given locations.
fm_covariance()
: Compute the covariance between "A1 x" and "A2 x", when
x is a basis vector with precision matrix Q
.
fm_sample()
: Generate n
samples based on a sparse precision matrix Q
library(Matrix)
mesh <- fm_mesh_1d(-20:120, degree = 2)
Q <- fm_matern_precision(mesh, alpha = 2, rho = 15, sigma = 1)
x <- seq(0, 100, length.out = 601)
A <- fm_basis(mesh, x)
plot(x,
as.vector(Matrix::diag(fm_covariance(Q, A))),
type = "l",
ylab = "marginal variances"
)
plot(x,
fm_evaluate(mesh, loc = x, field = fm_sample(1, Q)[, 1]),
type = "l",
ylab = "process sample"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.