Skip to contents

Constructs a mapper that aggregates elements of the input state, so it can be used e.g. for weighted summation or integration over blocks of values.


bru_mapper_aggregate(rescale = FALSE, n_block = 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)



logical; For bru_mapper_aggregate and bru_mapper_logsumexp, specifies if the blockwise sums should be normalised by the blockwise weight sums or not:

  • FALSE: (default) Straight weighted sum, no rescaling.

  • TRUE: Divide by the sum of the weight values within each block. This is useful for integration averages, when the given weights are plain integration weights. If the weights are NULL or all ones, this is the same as dividing by the number of entries in each block.


Predetermined number of output blocks. If NULL, overrides the maximum block index in the inputs.


A mapper S3 object, inheriting from bru_mapper.


Arguments passed on to other methods


Data input for the mapper.


A vector of latent state values for the mapping, of length ibm_n(mapper, inla_f = FALSE)


integer giving the length of the state vector for mappers that have state dependent output size.


Internal, optional pre-computed sub-mapper information


  • For bru_mapper_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.


m <- bru_mapper_aggregate()
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4), 11:14)
#> $offset
#> [1] 50 80
#> $jacobian
#> 2 x 4 sparse Matrix of class "dgCMatrix"
#> [1,] 1 . 3 .
#> [2,] . 2 . 4