Constructs a mapper that transforms the marginal distribution state
from
\(\textrm{N}(0,1)\) to the distribution of a given (continuous)
quantile function. The ...
arguments are used as parameter arguments to
qfun
, pfun
, dfun
, and dqfun
.
Usage
bru_mapper_marginal(
qfun,
pfun = NULL,
dfun = NULL,
dqfun = NULL,
...,
inverse = FALSE
)
# S3 method for class 'bru_mapper_marginal'
ibm_n(mapper, ..., state = NULL, n_state = NULL)
# S3 method for class 'bru_mapper_marginal'
ibm_n_output(mapper, input, state = NULL, ..., n_state = NULL)
# S3 method for class 'bru_mapper_marginal'
ibm_values(mapper, ..., state = NULL, n_state = NULL)
# S3 method for class 'bru_mapper_marginal'
ibm_jacobian(mapper, input, state = NULL, ..., reverse = FALSE)
# S3 method for class 'bru_mapper_marginal'
ibm_eval(mapper, input, state = NULL, ..., reverse = FALSE)
Arguments
- qfun
A quantile function, supporting
lower.tail
andlog.p
arguments, likestats::qnorm()
.- pfun
A CDF, supporting
lower.tail
andlog.p
arguments, likestats::pnorm()
. Only needed and used whenxor(mapper[["inverse"]], reverse)
isTRUE
in a method call. DefaultNULL
- dfun
A pdf, supporting
log
argument, likestats::dnorm()
. IfNULL
(default), uses finite differences onqfun
orpfun
instead.- dqfun
A function evaluating the reciprocal of the derivative of
qfun
. IfNULL
(default), usesdfun(qfun(...),...)
or finite differences onqfun
orpfun
instead.- ...
Arguments passed on to other methods
- inverse
logical; If
FALSE
(default),bru_mapper_marginal()
defines a mapping from standard Normal to a specified distribution. IfTRUE
, it defines a mapping from the specified distribution to a standard Normal.- mapper
A mapper S3 object, inheriting from
bru_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.
- input
Data input for the mapper.
- reverse
logical; control
bru_mapper_marginal
evaluation. DefaultFALSE
. WhenTRUE
, reverses the direction of the mapping, see details formarginal
mappers.
Methods (by generic)
ibm_jacobian(bru_mapper_marginal)
: Non-NULLinput
values are interpreted as a parameter list forqfun
, overriding that of the mapper itself.ibm_eval(bru_mapper_marginal)
: Whenxor(mapper[["inverse"]], reverse)
isFALSE
,ibm_eval()
formarginal
returnsqfun(pnorm(x), param)
, evaluated in a numerically stable way. Otherwise, evaluates the inverseqnorm(pfun(x, param))
instead.
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_matrix()
,
bru_mapper_mesh_B()
,
bru_mapper_multi()
,
bru_mapper_pipe()
,
bru_mapper_repeat()
,
bru_mapper_scale()
,
bru_mapper_shift()
,
bru_mapper_taylor()
Examples
m <- bru_mapper_marginal(qexp, pexp, rate = 1 / 8)
(val <- ibm_eval(m, state = -5:5))
#> [1] 2.293213e-06 2.533739e-04 1.080648e-02 1.841033e-01 1.382030e+00
#> [6] 5.545177e+00 1.472817e+01 3.026547e+01 5.286181e+01 8.288081e+01
#> [11] 1.205200e+02
ibm_eval(m, state = val, reverse = TRUE)
#> [1] -5 -4 -3 -2 -1 0 1 2 3 4 5
m <- bru_mapper_marginal(qexp, pexp, dexp, rate = 1 / 8)
ibm_eval2(m, state = -3:3)
#> $offset
#> [1] 0.01080648 0.18410327 1.38203023 5.54517744 14.72817316 30.26547467
#> [7] 52.86180977
#>
#> $jacobian
#> 7 x 7 diagonal matrix of class "ddiMatrix"
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 0.03550271 . . . . . .
#> [2,] . 0.4419829 . . . . .
#> [3,] . . 2.3008 . . . .
#> [4,] . . . 6.383076 . . .
#> [5,] . . . . 12.20108 . .
#> [6,] . . . . . 18.98572 .
#> [7,] . . . . . . 26.26479
#>