bm_factor: Mapper for factor variables

View source: R/mappers.R

bm_factorR Documentation

Mapper for factor variables

Description

Create a factor mapper

Usage

bm_factor(values, factor_mapping, indexed = FALSE)

bru_mapper_factor(...)

## S3 method for class 'bm_factor'
ibm_n(mapper, ...)

## S3 method for class 'bm_factor'
ibm_values(mapper, ...)

## S3 method for class 'bm_factor'
ibm_jacobian(mapper, input, ...)

Arguments

values

Input values calculated by bru_input.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, the ibm_values() method will return an integer vector instead of the factor levels. This is needed e.g. for group and replicate mappers, since INLA::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.

...

Arguments passed on to other methods

mapper

A mapper S3 object, inheriting from bru_mapper.

input

Data input for the mapper.

See Also

bru_mapper, bru_mapper_generics

Other mappers: bm_aggregate(), bm_collect(), bm_const(), bm_fmesher(), bm_harmonics(), bm_index(), bm_linear(), bm_logsumexp(), bm_marginal(), bm_matrix(), bm_mesh_B(), bm_multi(), bm_pipe(), bm_repeat(), bm_scale(), bm_shift(), bm_sum(), bm_taylor(), bru_get_mapper(), bru_mapper(), bru_mapper.fm_mesh_1d(), bru_mapper.fm_mesh_2d(), bru_mapper_generics

Examples

m <- bm_factor(factor(c("a", "b")), "full")
ibm_eval2(m, input = c("b", "a", "a", "b"), state = c(1, 3))

m <- bm_factor(factor(c("a", "b")), "contrast")
ibm_eval2(m, input = factor(c("b", "a", "a", "b")), state = 2)


inlabru-org/inlabru documentation built on July 17, 2025, 2:11 a.m.