Skip to contents

[Experimental] Constructs a mapper that adds elements of plogis(state), with optional non-negative weighting, and then optionally takes the qlogis(). Relies on the input handling methods for bm_aggregate. To avoid numerical issues, it uses plogis(x, log.p = TRUE), plogis(-x, log.p = TRUE), and the equivalent of one or two applications of bm_logsumexp() to evaluate either \(\log(p_k)-\log(1-p_k)\), \(\log(p_k)\), or \(p_k\) where

\(p_k=\sum_{i\in I_k} w_i / (1+e^{-\eta_i}) / \sum_{i\in I_k} w_i \)

or, for rescale = FALSE,

\(p_k=\sum_{i\in I_k} w_i / (1+e^{-\eta_i}) \)

Usage

bm_logitsum(
  n_block = NULL,
  rescale = FALSE,
  link = c("logit", "log", "identity")
)

Arguments

n_block

Predetermined number of output blocks. If NULL, overrides the maximum block index in the inputs. The priority order is input$n_block, the mapper definition n_block, then max(input$block).

rescale

logical; For bm_aggregate and bm_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.

character; Either "logit", "log", or "identity". The combination rescale = TRUE, link = "logit" is equivalent to the bm_logitaverage mapper. The combination rescale = FALSE, link = "logit" is not allowed, as the model is only valid if the weights sum to at most 1, and the < 1 cas has not been implemented. When link = "identity", no link function is applied.

Value

A bm_logitsum/bm_aggregate mapper object.

Examples

m <- bm_logitsum(rescale = FALSE, link = "identity")
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4), 11:14)
#> $offset
#> [1] 3.999977 5.999984
#> 
#> $jacobian
#> 2 x 4 sparse Matrix of class "dgCMatrix"
#>                                                         
#> [1,] 1.670114e-05 .            6.780958e-06 .           
#> [2,] .            1.228827e-05 .            3.326109e-06
#> 
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4, n_block = 3), 11:14)
#> $offset
#> [1] 3.999977 5.999984 0.000000
#> 
#> $jacobian
#> 3 x 4 sparse Matrix of class "dgCMatrix"
#>                                                         
#> [1,] 1.670114e-05 .            6.780958e-06 .           
#> [2,] .            1.228827e-05 .            3.326109e-06
#> [3,] .            .            .            .           
#>