The component definitions will automatically attempt to extract mapper
information from any model object by calling the generic bru_get_mapper
.
Any class method implementation should return a bru_mapper object suitable
for the given latent model.
Usage
bru_get_mapper(model, ...)
# S3 method for class 'inla.spde'
bru_get_mapper(model, ...)
# S3 method for class 'inla.rgeneric'
bru_get_mapper(model, ...)
# S3 method for class 'inla.cgeneric'
bru_get_mapper(model, ...)
bru_get_mapper_safely(model, ...)
Value
A bru_mapper object defined by the model component
Details
Before implementing your own bru_get_mapper
method, check if there
is already a general method available that handles your model class, such as
bru_get_mapper.inla.spde()
, bru_get_mapper.inla.rgeneric()
, and
bru_get_mapper.inla.cgeneric()
.
Methods (by class)
bru_get_mapper(inla.spde)
: Extract an indexed mapper for themodel$mesh
object contained in the model object, which is assumed to be of a class supporting relevantfmesher
methods.bru_get_mapper(inla.rgeneric)
: Returns the mapper given by a pre-computed mapper, a call toINLA::inla.rgeneric.q(model, cmd = "mapper")
(Note:cmd="mapper"
is not supported by INLA, at least not before 2025.08.17, so will be ignored), or an index mapper mapping the size of the model graph.The easiest method to define a mapper for an
inla.rgeneric
model is to store the mapper in the object. To support the function call version, add a"mapper"
option to thecmd
argument of yourrgeneric
definition function. Alternatively, define your model using a subclass and define a correspondingbru_get_mapper.<subclass>
method that should return the correspondingbru_mapper
object.If no
bru_get_mapper.<subclass>
method is defined, the order of precedence for the mapper construction inbru_get_mapper.<inla.rgeneric>
has the following precedence:model$mapper
inla.rgeneric.q(model, cmd = "mapper")
bm_index()
using the size of the graph returned byinla.rgeneric.q(model, cmd = "graph")
bru_get_mapper(inla.cgeneric)
: Returns the mapper given by a pre-computed mapper, or an index mapper mapping the size of the model graph fromINLA::inla.cgeneric.q(model)$graph
.
Functions
bru_get_mapper_safely()
: Tries to call thebru_get_mapper
, and returnsNULL
if it fails (e.g. due to no available class method). If the call succeeds and returns non-NULL
, it checks that the object inherits from thebru_mapper
class, and gives an error if it does not.
See also
bru_mapper for mapper constructor methods, and the individual mappers for specific implementation details.
Other mappers:
bm_aggregate()
,
bm_collect()
,
bm_const()
,
bm_factor()
,
bm_fm_mesh_1d
,
bm_fmesher()
,
bm_harmonics()
,
bm_index()
,
bm_linear()
,
bm_logsumexp()
,
bm_marginal()
,
bm_matrix()
,
bm_mesh_B()
,
bm_multi()
,
bm_pipe()
,
bm_repeat()
,
bm_scale()
,
bm_shift()
,
bm_sum()
,
bm_taylor()
,
bru_mapper()
Examples
if (bru_safe_inla()) {
library(INLA)
mesh <- fmesher::fm_rcdt_2d_inla(globe = 2)
spde <- inla.spde2.pcmatern(mesh,
prior.range = c(1, 0.5),
prior.sigma = c(1, 0.5)
)
mapper <- bru_get_mapper(spde)
ibm_n(mapper)
}
#> Loading required package: Matrix
#> This is INLA_25.06.22-1 built 2025-06-22 16:17:48 UTC.
#> - See www.r-inla.org/contact-us for how to get help.
#> - List available models/likelihoods/etc with inla.list.models()
#> - Use inla.doc(<NAME>) to access documentation
#> [1] 42