A bru_mapper
sub-class implementation must provide an
ibm_jacobian()
method. If the model size 'n' and definition
values 'values' are stored in the object itself, default methods are
available (see Details). Otherwise the
ibm_n()
and ibm_values()
methods also need to be provided.
Usage
# S3 method for bru_mapper_fm_mesh_2d
ibm_n(mapper, ...)
# S3 method for bru_mapper_fm_mesh_2d
ibm_values(mapper, ...)
# S3 method for bru_mapper_fm_mesh_2d
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_inla_mesh_2d
ibm_n(mapper, ...)
# S3 method for bru_mapper_inla_mesh_2d
ibm_values(mapper, ...)
# S3 method for bru_mapper_inla_mesh_2d
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_fm_mesh_1d
ibm_n(mapper, ...)
# S3 method for bru_mapper_fm_mesh_1d
ibm_values(mapper, ...)
# S3 method for bru_mapper_fm_mesh_1d
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_inla_mesh_1d
ibm_n(mapper, ...)
# S3 method for bru_mapper_inla_mesh_1d
ibm_values(mapper, ...)
# S3 method for bru_mapper_inla_mesh_1d
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_index
ibm_invalid_output(mapper, input, state, ...)
# S3 method for bru_mapper_index
ibm_jacobian(mapper, input, state, ...)
# S3 method for bru_mapper_taylor
ibm_n(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_taylor
ibm_n_output(mapper, input, ...)
# S3 method for bru_mapper_taylor
ibm_values(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_taylor
ibm_jacobian(mapper, ..., multi = FALSE)
# S3 method for bru_mapper_taylor
ibm_eval(mapper, input = NULL, state = NULL, ...)
# S3 method for bru_mapper_linear
ibm_n(mapper, ...)
# S3 method for bru_mapper_linear
ibm_values(mapper, ...)
# S3 method for bru_mapper_linear
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_matrix
ibm_n(mapper, ...)
# S3 method for bru_mapper_matrix
ibm_values(mapper, ...)
# S3 method for bru_mapper_matrix
ibm_jacobian(mapper, input, state = NULL, inla_f = FALSE, ...)
# S3 method for bru_mapper_factor
ibm_n(mapper, ...)
# S3 method for bru_mapper_factor
ibm_values(mapper, ...)
# S3 method for bru_mapper_factor
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_const
ibm_n(mapper, ...)
# S3 method for bru_mapper_const
ibm_values(mapper, ...)
# S3 method for bru_mapper_const
ibm_jacobian(mapper, input, ...)
# S3 method for bru_mapper_const
ibm_eval(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_scale
ibm_n(mapper, ..., state = NULL, n_state = NULL)
# S3 method for bru_mapper_scale
ibm_n_output(mapper, input, state = NULL, ..., n_state = NULL)
# S3 method for bru_mapper_scale
ibm_values(mapper, ..., state = NULL, n_state = NULL)
# S3 method for bru_mapper_scale
ibm_jacobian(mapper, input, state = NULL, ..., sub_lin = NULL)
# S3 method for bru_mapper_scale
ibm_eval(mapper, input, state = NULL, ..., sub_lin = NULL)
# S3 method for bru_mapper_aggregate
ibm_n(mapper, ..., input = NULL, state = NULL, n_state = NULL)
# S3 method for bru_mapper_aggregate
ibm_n_output(mapper, input = NULL, ...)
# S3 method for bru_mapper_aggregate
ibm_values(mapper, ..., state = NULL, n_state = NULL)
# S3 method for bru_mapper_aggregate
ibm_jacobian(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_aggregate
ibm_eval(mapper, input, state = NULL, ..., sub_lin = NULL)
# S3 method for bru_mapper_logsumexp
ibm_jacobian(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_logsumexp
ibm_eval(mapper, input, state = NULL, log = TRUE, ..., sub_lin = NULL)
# S3 method for bru_mapper_marginal
ibm_n(mapper, ..., state = NULL, n_state = NULL)
# S3 method for bru_mapper_marginal
ibm_n_output(mapper, input, state = NULL, ..., n_state = NULL)
# S3 method for bru_mapper_marginal
ibm_values(mapper, ..., state = NULL, n_state = NULL)
# S3 method for bru_mapper_marginal
ibm_jacobian(mapper, input, state = NULL, ..., reverse = FALSE)
# S3 method for bru_mapper_marginal
ibm_eval(mapper, input, state = NULL, ..., reverse = FALSE)
# S3 method for bru_mapper_pipe
ibm_n(mapper, ..., input = NULL, state = NULL)
# S3 method for bru_mapper_pipe
ibm_n_output(mapper, input, state = NULL, ..., n_state = NULL)
# S3 method for bru_mapper_pipe
ibm_values(mapper, ...)
# S3 method for bru_mapper_pipe
ibm_jacobian(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_pipe
ibm_eval(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_pipe
ibm_eval2(mapper, input, state = NULL, ...)
# S3 method for bru_mapper_pipe
ibm_simplify(mapper, input = NULL, state = NULL, ..., n_state = NULL)
# S3 method for bru_mapper_multi
ibm_n(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_multi
ibm_n_output(mapper, input, ...)
# S3 method for bru_mapper_multi
ibm_values(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_multi
ibm_is_linear(mapper, multi = FALSE, ...)
# S3 method for bru_mapper_multi
ibm_jacobian(
mapper,
input,
state = NULL,
inla_f = FALSE,
multi = FALSE,
...,
sub_A = NULL
)
# S3 method for bru_mapper_multi
ibm_linear(mapper, input, state, inla_f = FALSE, ...)
# S3 method for bru_mapper_multi
ibm_eval(
mapper,
input,
state = NULL,
inla_f = FALSE,
...,
jacobian = NULL,
pre_A = deprecated()
)
# S3 method for bru_mapper_multi
ibm_invalid_output(mapper, input, state, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_multi
[(x, i, drop = TRUE)
# S3 method for bru_mapper_multi
ibm_names(mapper)
# S3 method for bru_mapper_multi
ibm_names(mapper) <- value
# S3 method for bru_mapper_collect
ibm_n(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_collect
ibm_n_output(mapper, input, state = NULL, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_collect
ibm_values(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_collect
ibm_is_linear(mapper, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_collect
ibm_jacobian(
mapper,
input,
state = NULL,
inla_f = FALSE,
multi = FALSE,
...,
sub_lin = NULL
)
# S3 method for bru_mapper_collect
ibm_eval(
mapper,
input,
state,
inla_f = FALSE,
multi = FALSE,
...,
sub_lin = NULL
)
# S3 method for bru_mapper_collect
ibm_linear(mapper, input, state, inla_f = FALSE, ...)
# S3 method for bru_mapper_collect
ibm_invalid_output(mapper, input, state, inla_f = FALSE, multi = FALSE, ...)
# S3 method for bru_mapper_collect
[(x, i, drop = TRUE)
# S3 method for bru_mapper_collect
ibm_names(mapper)
# S3 method for bru_mapper_collect
ibm_names(mapper) <- value
# S3 method for bru_mapper_harmonics
ibm_n(mapper, inla_f = FALSE, ...)
# S3 method for bru_mapper_harmonics
ibm_jacobian(mapper, input, state = NULL, inla_f = FALSE, ...)
# S3 method for bru_mapper_mesh_B
ibm_n(mapper, ...)
# S3 method for bru_mapper_mesh_B
ibm_values(mapper, ...)
# S3 method for bru_mapper_mesh_B
ibm_jacobian(mapper, input, ...)
Arguments
- mapper
A mapper S3 object, inheriting from
bru_mapper
.- ...
Arguments passed on to other methods
- input
The values for which to produce a mapping matrix
- state
A vector of latent state values for the mapping, of length
ibm_n(mapper, inla_f = FALSE)
- inla_f
logical; when
TRUE
foribm_n()
andibm_values()
, the result must be compatible with theINLA::f(...)
and correspondingINLA::inla.stack(...)
constructions. Foribm_{eval,jacobian,linear}
, theinput
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 bybru_mapper_collect
.- multi
logical; If
TRUE
(or positive), recurse one level into sub-mappers- n_state
integer giving the length of the state vector for mappers that have state dependent output size.
- sub_lin
Internal, optional pre-computed sub-mapper information
- log
logical; control
log
output. DefaultTRUE
, see theibm_eval()
details forlogsumexp
mappers.- reverse
logical; control
bru_mapper_marginal
evaluation. DefaultFALSE
. WhenTRUE
, reverses the direction of the mapping, see details formarginal
mappers.- sub_A
Internal; precomputed Jacobian matrices.
- jacobian
For
ibm_eval()
methods, an optional pre-computed Jacobian, typically supplied by internal methods that already have the Jacobian.- pre_A
- x
object from which to extract element(s)
- i
indices specifying element(s) to extract
- drop
logical; For
[.bru_mapper_collect
, whether to extract an individual mapper wheni
identifies a single element. IfFALSE
, a list of sub-mappers is returned (suitable e.g. for creating a newbru_mapper_collect
object). Default:TRUE
- value
a character vector of up to the same length as the number of mappers in the multi-mapper x
Value
[
-indexing abru_mapper_multi
extracts a subsetbru_mapper_multi
object (for dropFALSE
) or an individual sub-mapper (for dropTRUE
, andi
identifies a single element)
[
-indexing abru_mapper_collect
extracts a subsetbru_mapper_collect
object (for dropFALSE
) or an individual sub-mapper (for dropTRUE
, andi
identifies a single element)
The
names()
method forbru_mapper_collect
returns the names from the sub-mappers list
Details
The
ibm_eval.bru_mapper_taylor()
evaluates linearised mapper information at the givenstate
. Theinput
argument is ignored, so that the usual argument orderibm_eval(mapper, input, state)
syntax can be used, but alsoibm_eval(mapper, state = state)
. For a mapper with a named jacobian list, thestate
argument must also be a named list. Ifstate
isNULL
, all-zero is assumed.
For bru_mapper_scale
, input
values without a scale
element
are interpreted as no scaling.
For
bru_mapper_aggregate
,input
should be a list with elementsblock
andweights
.block
should be a vector of the same length as thestate
, orNULL
, withNULL
equivalent to all-1. Ifweights
isNULL
, it's interpreted as all-1.
For
bru_mapper_logsumexp
,input
should be a list with elementsblock
andweights
.block
should be a vector of the same length as thestate
, orNULL
, withNULL
equivalent to all-1. Ifweights
isNULL
, it's interpreted as all-1.
For bru_mapper_marginal
, non-NULL input
values are interpreted
as a parameter list for qfun
, overriding that of the mapper itself.
ibm_jacobian
forbru_mapper_multi
accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, seeibm_names.bru_mapper_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_invalid_output
forbru_mapper_multi
accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, seeibm_names.bru_mapper_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
forbru_mapper_collect
accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, seeibm_names.bru_mapper_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=TRUE
andhidden=TRUE
in the mapper definition, the input format should instead match that of the first, non-hidden, sub-mapper.
ibm_invalid_output
forbru_mapper_collect
accepts a list with named entries, or a list with unnamed but ordered elements. The names must match the sub-mappers, seeibm_names.bru_mapper_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.
Functions
ibm_eval(bru_mapper_logsumexp)
: Whenlog
isTRUE
(default),ibm_eval()
forlogsumexp
returns the log-sum-weight-exp value. IfFALSE
, thesum-weight-exp
value is returned.ibm_eval(bru_mapper_marginal)
: Whenxor(mapper[["inverse"]], reverse)
isFALSE
,ibm_eval()
formarginal
returnsqfun(pnorm(x), param)
, evaluated in a numerically stable way. Otherwise, evaluates the inverseqnorm(pfun(x, param))
instead.ibm_simplify(bru_mapper_pipe)
: Constructs a simplifiedpipe
mapper. For fully linear pipes, callsibm_linear()
. For partially non-linear pipes, replaces each sequence of linear mappers with a singlebru_mapper_taylor()
mapper, while keeping the full list of original mapper names, allowing the originalinput
structure to be used also with the simplified mappers, since thetaylor
mappers are not dependent on inputs.ibm_names(bru_mapper_multi)
: Returns the names from the sub-mappers list
See also
bru_mapper for constructor methods, and bru_get_mapper for hooks to extract mappers from latent model object class objects.