Create a factor mapper
Usage
bru_mapper_factor(values, factor_mapping, indexed = FALSE)
# S3 method for class 'bru_mapper_factor'
ibm_n(mapper, ...)
# S3 method for class 'bru_mapper_factor'
ibm_values(mapper, ...)
# S3 method for class 'bru_mapper_factor'
ibm_jacobian(mapper, input, ...)
Arguments
- values
Input values calculated by
input_eval.bru_input()
- factor_mapping
character; selects the type of factor mapping.
'contrast'
for leaving out the first factor level.'full'
for keeping all levels.
- indexed
logical; if
TRUE
, theibm_values()
method will return an integer vector instead of the factor levels. This is needed e.g. forgroup
andreplicate
mappers, sinceINLA::f()
doesn't accept factor values. Default:FALSE
, which works for the main input mappers. The default mapper constructions will set it the required setting.- mapper
A mapper S3 object, inheriting from
bru_mapper
.- ...
Arguments passed on to other methods
- input
Data input for the mapper.
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_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_repeat()
,
bru_mapper_scale()
,
bru_mapper_shift()
,
bru_mapper_sum()
,
bru_mapper_taylor()
Examples
m <- bru_mapper_factor(factor(c("a", "b")), "full")
ibm_eval2(m, input = c("b", "a", "a", "b"), state = c(1, 3))
#> $offset
#> [1] 3 1 1 3
#>
#> $jacobian
#> 4 x 2 sparse Matrix of class "dgCMatrix"
#>
#> [1,] . 1
#> [2,] 1 .
#> [3,] 1 .
#> [4,] . 1
#>
m <- bru_mapper_factor(factor(c("a", "b")), "contrast")
ibm_eval2(m, input = factor(c("b", "a", "a", "b")), state = 2)
#> $offset
#> [1] 2 0 0 2
#>
#> $jacobian
#> 4 x 1 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1
#> [2,] .
#> [3,] .
#> [4,] 1
#>