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 isinput$n_block, the mapper definitionn_block, thenmax(input$block).- rescale
logical; For
bm_aggregateandbm_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 areNULLor all ones, this is the same as dividing by the number of entries in each block.
- link
character; Either "logit", "log", or "identity". The combination
rescale = TRUE, link = "logit"is equivalent to the bm_logitaverage mapper. The combinationrescale = FALSE, link = "logit"is not allowed, as the model is only valid if the weights sum to at most 1, and the< 1cas has not been implemented. Whenlink = "identity", no link function is applied.
See also
bru_mapper, bru_mapper_generics
Other mappers:
bm_aggregate(),
bm_collect(),
bm_const(),
bm_expr(),
bm_factor(),
bm_fm_mesh_1d,
bm_fmesher(),
bm_harmonics(),
bm_index(),
bm_linear(),
bm_logitaverage(),
bm_logsumexp(),
bm_marginal(),
bm_matrix(),
bm_multi(),
bm_pipe(),
bm_reparam(),
bm_repeat(),
bm_scale(),
bm_shift(),
bm_sum(),
bm_taylor(),
bru_get_mapper(),
bru_mapper()
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,] . . . .
#>