ibm_jacobian: Jacobian of a mapper

View source: R/mappers.R

ibm_jacobianR Documentation

Jacobian of a mapper

Description

Implementations must return a (sparse) matrix of size ibm_n_output(mapper, input, inla_f) by ibm_n(mapper, inla_f = FALSE). The inla_f=TRUE argument should only affect the allowed type of input format.

Usage

ibm_jacobian(mapper, input, state = NULL, inla_f = FALSE, ...)

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

## S3 method for class 'bm_fmesher'
ibm_jacobian(mapper, input, ...)

## S3 method for class 'bm_fm_mesh_1d'
ibm_jacobian(mapper, input, ...)

## S3 method for class 'bm_index'
ibm_jacobian(mapper, input, state, ...)

## S3 method for class 'bm_taylor'
ibm_jacobian(mapper, ..., multi = FALSE)

## S3 method for class 'bm_linear'
ibm_jacobian(mapper, input, ...)

## S3 method for class 'bm_matrix'
ibm_jacobian(mapper, input, state = NULL, inla_f = FALSE, ...)

## S3 method for class 'bm_factor'
ibm_jacobian(mapper, input, ...)

## S3 method for class 'bm_const'
ibm_jacobian(mapper, input, ...)

## S3 method for class 'bm_shift'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_scale'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_aggregate'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_logsumexp'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_logitaverage'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_marginal'
ibm_jacobian(mapper, input, state = NULL, ..., reverse = FALSE)

## S3 method for class 'bm_pipe'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_multi'
ibm_jacobian(
  mapper,
  input,
  state = NULL,
  inla_f = FALSE,
  multi = FALSE,
  ...,
  sub_A = NULL
)

## S3 method for class 'bm_harmonics'
ibm_jacobian(mapper, input, state = NULL, inla_f = FALSE, ...)

## S3 method for class 'bm_reparam'
ibm_jacobian(mapper, input, state = NULL, ...)

## S3 method for class 'bm_collect'
ibm_jacobian(
  mapper,
  input,
  state = NULL,
  inla_f = FALSE,
  multi = FALSE,
  ...,
  sub_lin = NULL
)

## S3 method for class 'bm_expr'
ibm_jacobian(
  mapper,
  input,
  state = NULL,
  inla_f = FALSE,
  ...,
  derived = NULL,
  jacobians = NULL,
  data = NULL,
  multi = FALSE,
  offset = NULL,
  eps = 1e-06,
  .envir = rlang::caller_env()
)

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

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

## S3 method for class 'bm_repeat'
ibm_jacobian(
  mapper,
  input,
  state = NULL,
  inla_f = FALSE,
  multi = FALSE,
  ...,
  sub_lin = NULL
)

## S3 method for class 'bm_sum'
ibm_jacobian(
  mapper,
  input,
  state = NULL,
  inla_f = FALSE,
  multi = FALSE,
  ...,
  sub_lin = 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)

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.

...

Arguments passed on to other methods

multi

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

reverse

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

sub_A

Internal; precomputed Jacobian matrices.

sub_lin

Internal, optional pre-computed sub-mapper information

derived

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

jacobians

The state vectors of variables derived from the root If jacobians is NULL or missing, defaults to an empty list. If not NULL, should be a list with named entries, one for variable derived from the root variables. Each list element should be a named list of Jacobian matrices, with names matching the root variables. Missing entries are treated as all-zero matrices.

data

A list with data objects, with the main object called data; see bm_expr()

offset

The offset value, pre-calculated by ibm_eval.bm_expr().

eps

The finite difference step size to use for numerical differentiation. Default is 1e-6.

.envir

The environment for the expression evaluation. By default, this is set to the caller environment.

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 (sparse) matrix of size ibm_n_output(mapper, input, inla_f) by ibm_n(mapper, inla_f = FALSE).

Methods (by class)

  • ibm_jacobian(default): Mapper classes must implement their own ibm_jacobian method.

  • ibm_jacobian(bm_fmesher): Returns the fmesher::fm_basis() matrix of the mesh being mapped.

  • ibm_jacobian(bm_fm_mesh_1d): Returns the fmesher::fm_basis() matrix of the mesh being mapped.

  • ibm_jacobian(bm_matrix): Accepts input as a matrix, Matrix, Spatial, or sfc_POINT object.

  • ibm_jacobian(bm_shift): input NULL values are interpreted as no shift.

  • ibm_jacobian(bm_scale): input NULL values are interpreted as no scaling.

  • ibm_jacobian(bm_aggregate): input should be a list with elements block and weights. block should be a vector of the same length as the state, or NULL, with NULL equivalent to all-1. If weights is NULL, it's interpreted as all-1.

  • ibm_jacobian(bm_logsumexp): input should be a list with elements block and weights. block should be a vector of the same length as the state, or NULL, with NULL equivalent to all-1. If weights is NULL, it's interpreted as all-1.

  • ibm_jacobian(bm_logitaverage): input should be a list with elements block and weights. block should be a vector of the same length as the state, or NULL, with NULL equivalent to all-1. If weights is NULL, it's interpreted as all-1.

  • ibm_jacobian(bm_marginal): Non-NULL input values are interpreted as a parameter list for qfun, overriding that of the mapper itself.

  • ibm_jacobian(bm_multi): Accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, see ibm_names.bm_multi(). Each list element should take a format accepted by the corresponding sub-mapper. In case each element is a vector, the input can be given as a data.frame with named columns, a matrix with named columns, or a matrix with unnamed but ordered columns.

  • ibm_jacobian(bm_collect): Accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, see ibm_names.bm_collect(). Each list element should take a format accepted by the corresponding sub-mapper. In case each element is a vector, the input can be given as a data.frame with named columns, a matrix with named columns, or a matrix with unnamed but ordered columns. When inla_f=TRUE and hidden=TRUE in the mapper definition, the input format should instead match that of the first, non-hidden, sub-mapper.

  • ibm_jacobian(bm_expr): Accepts a state list with named entries, one for each variable. The input format should match the description given for bm_expr().

  • ibm_jacobian(bm_repeat): The input should take the format of the repeated submapper.

  • ibm_jacobian(bm_sum): Accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, see ibm_names.bm_sum(). Each list element should take a format accepted by the corresponding sub-mapper. In case each element is a vector, the input can be given as a data.frame with named columns, a matrix with named columns, or a matrix with unnamed but ordered columns.

See Also

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

Examples

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


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