Learn R Programming

inlabru (version 2.8.0)

bru_get_mapper: Extract mapper information from INLA model component objects

Description

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 inla.spde bru_get_mapper(model, ...)

# S3 method for inla.rgeneric bru_get_mapper(model, ...)

bru_get_mapper_safely(model, ...)

Value

A bru_mapper object defined by the model component

Arguments

model

A model component object

...

Arguments passed on to other methods

Details

  • bru_get_mapper.inla.spde extract an indexed mapper for the model$mesh object contained in the model object. It returns NULL gives a warning if no known mesh type is found in the model object.

  • bru_get_mapper.inla.rgeneric returns the mapper given by a call to model$f$rgeneric$definition("mapper"). To support this for your own inla.rgeneric models, add a "mapper" option to the cmd argument of your rgeneric definition function. You will need to store the mapper in your object as well. Alternative, define your model using a subclass and define a corresponding bru_get_mapper.subclass method that should return the corresponding bru_mapper object.

  • bru_get_mapper_safely tries to call the bru_get_mapper, and returns NULL 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 the bru_mapper class, and gives an error if it does not.

See Also

bru_mapper for mapper constructor methods, and bru_mapper_methods for method generics and specific implementations.

Examples

Run this code
if (bru_safe_inla(quietly = TRUE)) {
  library(INLA)
  mesh <- inla.mesh.create(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)
}

Run the code above in your browser using DataLab