Create a pipe mapper, where mappers
is a list of mappers,
and the evaluated output of each mapper is handed as the state to the next
mapper.
The input
format for the ibm_eval
and ibm_jacobian
methods is
a list of inputs, one for each mapper.
Usage
bru_mapper_pipe(mappers)
# S3 method for class 'bru_mapper_pipe'
ibm_n(mapper, ..., input = NULL, state = NULL)
# S3 method for class 'bru_mapper_pipe'
ibm_n_output(mapper, input, state = NULL, ..., n_state = NULL)
# S3 method for class 'bru_mapper_pipe'
ibm_values(mapper, ...)
# S3 method for class 'bru_mapper_pipe'
ibm_jacobian(mapper, input, state = NULL, ...)
# S3 method for class 'bru_mapper_pipe'
ibm_eval(mapper, input, state = NULL, ...)
# S3 method for class 'bru_mapper_pipe'
ibm_eval2(mapper, input, state = NULL, ...)
# S3 method for class 'bru_mapper_pipe'
ibm_simplify(
mapper,
input = NULL,
state = NULL,
inla_f = FALSE,
...,
n_state = NULL
)
Arguments
- mappers
A list of
bru_mapper
objects- mapper
A mapper S3 object, inheriting from
bru_mapper
.- ...
Arguments passed on to other methods
- input
Data input for the mapper.
- state
A vector of latent state values for the mapping, of length
ibm_n(mapper, inla_f = FALSE)
- n_state
integer giving the length of the state vector for mappers that have state dependent output size.
- 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
.
Methods (by generic)
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.
See also
bru_mapper, bru_mapper_generics
Other mappers:
bru_get_mapper()
,
bru_mapper()
,
bru_mapper.fm_mesh_1d()
,
bru_mapper.fm_mesh_2d()
,
bru_mapper_aggregate()
,
bru_mapper_collect()
,
bru_mapper_const()
,
bru_mapper_factor()
,
bru_mapper_fmesher()
,
bru_mapper_generics
,
bru_mapper_harmonics()
,
bru_mapper_index()
,
bru_mapper_linear()
,
bru_mapper_logsumexp()
,
bru_mapper_marginal()
,
bru_mapper_matrix()
,
bru_mapper_mesh_B()
,
bru_mapper_multi()
,
bru_mapper_repeat()
,
bru_mapper_scale()
,
bru_mapper_shift()
,
bru_mapper_taylor()
Examples
m <- bru_mapper_pipe(list(
scale = bru_mapper_scale(),
shift = bru_mapper_shift()
))
ibm_eval2(m, input = list(scale = 2, shift = 1:4), state = 1:4)
#> $offset
#> [1] 3 6 9 12
#>
#> $jacobian
#> 4 x 4 diagonal matrix of class "ddiMatrix"
#> [,1] [,2] [,3] [,4]
#> [1,] 2 . . .
#> [2,] . 2 . .
#> [3,] . . 2 .
#> [4,] . . . 2
#>