ibm_eval: Evaluate a mapping

View source: R/mappers.R

ibm_evalR Documentation

Evaluate a mapping

Description

Implementations must return a vector of length ibm_n_output(). The input contents must be in a format accepted by ibm_jacobian() for the mapper.

Specific implementations for bm_aggregate, bm_collect, bm_const, bm_expr, bm_list, bm_logitaverage, bm_logsumexp, bm_marginal, bm_multi, bm_pipe, bm_reparam, bm_repeat, bm_scale, bm_shift, bm_sum, bm_taylor, bru_comp, bru_comp_list, bru_model, bru_obs, bru_obs_list, default.

Usage

ibm_eval(mapper, input, state = NULL, ...)

## Default S3 method:
ibm_eval(mapper, input, state = NULL, ..., jacobian = NULL)

## S3 method for class 'bru_obs'
ibm_eval(
  mapper,
  input,
  state,
  ...,
  multi = FALSE,
  comp_mappers,
  eval_fun = NULL
)

## S3 method for class 'bru_obs_list'
ibm_eval(
  mapper,
  input,
  state,
  ...,
  multi = FALSE,
  comp_mappers,
  eval_fun = NULL
)

Arguments

mapper

A mapper S3 object, inheriting from bru_mapper.

input

Data input for the mapper.

state

A vector of latent state values for the mapping, of length ibm_n(mapper, inla_f = FALSE)

...

Arguments passed on to ibm_eval_methods

log

logical; control log output. Default TRUE, see the ibm_eval() details for logsumexp mappers.

logit

logical; control logit output. Default TRUE, see the ibm_eval() details for logitaverage mappers.

reverse

logical; control bm_marginal evaluation. Default FALSE. When TRUE, reverses the direction of the mapping, see details for marginal mappers.

pre_A

[Deprecated] in favour of jacobian.

sub_lin

Internal, optional pre-computed sub-mapper information

data_mask

A data mask object to use for evaluating the expression. If NULL or missing, a data mask will be constructed with bru_data_mask() from the data, state, derived, and .envir arguments. This can be used to avoid redundant construction of the data mask when evaluating different expressions multiple times with the same input and state.

.envir

The environment in which to evaluate the expression. By default, this is set to the caller environment.

derived

The state vectors of variables derived from the root variables. If NULL or missing, defaults to an empty list.

inla_f

logical; when TRUE for ibm_n() and ibm_values(), the result must be compatible with the INLA::f(...) and corresponding INLA::inla.stack(...) constructions. For ⁠ibm_{eval,jacobian,linear}⁠, the input interpretation may be different. Implementations do not normally need to do anything different, except for mappers of the type needed for hidden multicomponent models such as "bym2", which can be handled by bm_collect.

data

should be a list with data objects, with the main object called data; see bm_expr() for details.

jacobian

For ibm_eval() methods, an optional pre-computed Jacobian, typically supplied by internal methods that already have the Jacobian.

multi

logical; If TRUE (or positive), recurse one level into sub-mappers

comp_mappers

A list of mappers, typically from ⁠as_bm_list<bru_comp_list>⁠.

eval_fun

A list of functions, typically from bru_eval_fun().

Value

A vector of length ibm_n_output(mapper, input, state, ...).

Methods (by class)

  • ibm_eval(default): Verifies that the mapper is linear with ibm_is_linear(), and then computes a linear mapping as ibm_jacobian(...) %*% state. When state is NULL, a zero vector of length ibm_n_output() is returned.

See Also

Other mapper methods: bru_mapper_generics, ibm_as_taylor(), ibm_eval2(), ibm_inla_subset(), ibm_invalid_output(), ibm_is_linear(), ibm_is_rowwise(), ibm_jacobian(), ibm_n(), ibm_n_output(), ibm_names(), ibm_simplify(), ibm_values()

Examples

m <- bm_linear()
ibm_eval(m, input = c(1, 3, 4, 5, 2), state = 2)


inlabru documentation built on July 28, 2026, 9:07 a.m.