| fm_gmrf {fmesher} | R Documentation | 
SPDE, GMRF, and Matérn process methods
Description
Usage
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)
Arguments
| x | A mesh object, e.g. from  | 
| alpha | The SPDE operator order. The resulting smoothness index
is  | 
| rho | The Matérn range parameter
(scale parameter  | 
| sigma | The nominal Matérn std.dev. parameter | 
| n | The number of samples to generate | 
| loc | locations to evaluate the random field, compatible with
 | 
| Q | A precision matrix | 
| A1,A2 | Matrices, typically obtained from  | 
| partial | 
 | 
| mu | Optional mean vector | 
| constr | Optional list of constraint information, with elements
 | 
Value
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)
Functions
-  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 matrixQ.
-  fm_sample(): Generatensamples based on a sparse precision matrixQ
Examples
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"
)