Defines a repeated-space mapper that sums the contributions for
each copy. The ibm_n()
method returns ibm_n(mapper) * n_rep
, and
ibm_values()
returns seq_len(ibm_n(mapper))
.
Usage
bru_mapper_repeat(mapper, n_rep, interleaved = FALSE)
# S3 method for class 'bru_mapper_repeat'
ibm_n(mapper, ...)
# S3 method for class 'bru_mapper_repeat'
ibm_n_output(mapper, ...)
# S3 method for class 'bru_mapper_repeat'
ibm_values(mapper, ...)
# S3 method for class 'bru_mapper_repeat'
ibm_jacobian(
mapper,
input,
state = NULL,
inla_f = FALSE,
multi = FALSE,
...,
sub_lin = NULL
)
# S3 method for class 'bru_mapper_repeat'
ibm_eval(mapper, input, state, multi = FALSE, ..., sub_lin = NULL)
# S3 method for class 'bru_mapper_repeat'
ibm_linear(mapper, input, state, ...)
# S3 method for class 'bru_mapper_repeat'
ibm_invalid_output(mapper, input, state, ...)
Arguments
- mapper
The mapper to be repeated.
- n_rep
The number of times to repeat the mapper. If a vector, the non-interleaved repeats are combined into a single repeat mapping, and combined with interleaved repeats via a
bru_mapper_sum()
of mappers.- interleaved
logical; if
TRUE
, the repeated mapping columns are interleaved;(x1[1], x2[1], ..., x1[2], x2[2], ...)
. IfFALSE
(default), the repeated mapping columns are contiguous,(x1[1], x1[2], ..., x2[1], x2[2], ...)
, and the Jacobian is acbind()
of the Jacobians of the repeated mappers.If
n_rep
is a vector,interleaved
should either be a single logical, or a vector of the same length. Each element applies to the correspondingn_rep
repetition specification.- ...
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)
- 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- sub_lin
Internal, optional pre-computed sub-mapper information
Methods (by generic)
ibm_jacobian(bru_mapper_repeat)
: The input should take the format of the repeated submapper.ibm_invalid_output(bru_mapper_repeat)
: Passes on the input to the corresponding method.
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_pipe()
,
bru_mapper_scale()
,
bru_mapper_shift()
,
bru_mapper_sum()
,
bru_mapper_taylor()
Examples
(m0 <- bru_mapper_index(3))
#> index
(m <- bru_mapper_repeat(m0, 5))
#> repeat(5 x index)
ibm_n(m)
#> [1] 15
ibm_values(m)
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ibm_jacobian(m, 1:3)
#> 3 x 15 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1 . . 1 . . 1 . . 1 . . 1 . .
#> [2,] . 1 . . 1 . . 1 . . 1 . . 1 .
#> [3,] . . 1 . . 1 . . 1 . . 1 . . 1
ibm_eval(m, 1:3, seq_len(ibm_n(m)))
#> [1] 35 40 45
# Interleaving and grouping
(m <- bru_mapper_repeat(m0, c(2, 1, 2), c(TRUE, FALSE, FALSE)))
#> sum(1 = repeat(2 x index, interleaved), 2 = repeat(3 x index))
ibm_n(m)
#> [1] 15
ibm_values(m)
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ibm_jacobian(m, 1:3)
#> 3 x 15 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1 1 . . . . 1 . . 1 . . 1 . .
#> [2,] . . 1 1 . . . 1 . . 1 . . 1 .
#> [3,] . . . . 1 1 . . 1 . . 1 . . 1
ibm_eval(m, 1:3, seq_len(ibm_n(m)))
#> [1] 33 40 47