Jacobian of a mapper
Source:R/mappers.R, R/mapper_collect.R, R/mapper_expr.R, and 2 more
ibm_jacobian.RdImplementations 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
TRUEforibm_n()andibm_values(), the result must be compatible with theINLA::f(...)and correspondingINLA::inla.stack(...)constructions. Foribm_{eval,jacobian,linear}, theinputinterpretation 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 bybm_collect.- ...
Arguments passed on to other methods
- multi
logical; If
TRUE(or positive), recurse one level into sub-mappers- reverse
logical; control
bm_marginalevaluation. DefaultFALSE. WhenTRUE, reverses the direction of the mapping, see details formarginalmappers.- 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
NULLor missing, defaults to an empty list.- jacobians
The state vectors of variables derived from the root If
jacobiansisNULLor missing, defaults to an empty list. If notNULL, 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; seebm_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 ownibm_jacobianmethod.ibm_jacobian(bm_fmesher): Returns thefmesher::fm_basis()matrix of the mesh being mapped.ibm_jacobian(bm_fm_mesh_1d): Returns thefmesher::fm_basis()matrix of the mesh being mapped.ibm_jacobian(bm_matrix): Acceptsinputas a matrix,Matrix,Spatial, orsfc_POINTobject.ibm_jacobian(bm_shift):inputNULL values are interpreted as no shift.ibm_jacobian(bm_scale):inputNULL values are interpreted as no scaling.ibm_jacobian(bm_aggregate):inputshould be a list with elementsblockandweights.blockshould be a vector of the same length as thestate, orNULL, withNULLequivalent to all-1. IfweightsisNULL, it's interpreted as all-1.ibm_jacobian(bm_logsumexp):inputshould be a list with elementsblockandweights.blockshould be a vector of the same length as thestate, orNULL, withNULLequivalent to all-1. IfweightsisNULL, it's interpreted as all-1.ibm_jacobian(bm_logitaverage):inputshould be a list with elementsblockandweights.blockshould be a vector of the same length as thestate, orNULL, withNULLequivalent to all-1. IfweightsisNULL, it's interpreted as all-1.ibm_jacobian(bm_marginal): Non-NULLinputvalues are interpreted as a parameter list forqfun, 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, seeibm_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, seeibm_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. Wheninla_f=TRUEandhidden=TRUEin the mapper definition, the input format should instead match that of the first, non-hidden, sub-mapper.ibm_jacobian(bm_expr): Accepts astatelist with named entries, one for each variable. Theinputformat should match the description given forbm_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, seeibm_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()