Extract the index vector for a
bru_obs() predictor,
or the whole or a subset of a full bru() predictor.
Usage
bru_index(object, ...)
# S3 method for class 'bru_obs'
bru_index(object, what = NULL, ...)
# S3 method for class 'bru_obs_list'
bru_index(object, tag = NULL, what = NULL, ...)
# S3 method for class 'bru'
bru_index(object, tag = NULL, what = NULL, ...)
# S3 method for class 'bru_comp'
bru_index(object, inla_f, ...)
# S3 method for class 'bru_comp_list'
bru_index(object, inla_f, ...)
# S3 method for class 'bru_model'
bru_index(object, used, ...)
index_eval(...)Arguments
- object
A component.
- ...
Arguments passed on to sub-methods.
- what
characterorNULL; One ofNULL, "all", "observed", and "missing". IfNULL(default) or "all", gives the index vector for the full sub-model predictor. If "observed", gives the index vector for the observed part (response is notNA). If "missing", gives the index vector for the missing part (response isNA) of the model.- tag
characterorinteger; Either a character vector identifying the tags of one or more of thebru_obs()observation models, or an integer vector identifying models by theirbru()specification order. IfNULL(default) computes indices for all sub-models.- inla_f
logical; when
TRUE, must result in values compatible withINLA::f(...)an specification and correspondingINLA::inla.stack(...)constructions.- used
A
bru_used()object
Value
bru_index(bru_obs): Anintegervector.
bru_index(bru_obs_list): Anintegervector.
bru_index(bru): Anintegervector.
bru_index(bru_comp): A list of indices into the latent variables compatible with the component mapper.
bru_index(bru_comp_list): A list of list of indices into the latent variables compatible with each component mapper.
bru_index(bru_model): A named list ofidx_fullandidx_inla, named list of indices, andinla_subset, andinla_subset, a named list of logical subset specifications for extracting theINLA::f()compatible index subsets.
Methods (by class)
bru_index(bru_obs): Extract the index vector for the predictor vector for abru_obs()sub-model. The indices are relative to the sub-model, and need to be appropriately offset to be used in the full model predictor.bru_index(bru_obs_list): Extract the index vector for "APredictor" for one or more specified observationbru_obs()sub-models. Accepts any combination oftagandwhat.bru_index(bru): Extract the index vector for "APredictor" for one or more specified observationbru_obs()sub-models. Accepts any combination oftagandwhat.bru_index(bru_model): Compute all index values for abru_model()object. Computes the index value matrices for included components according to theusedargument.
Author
Fabian E. Bachl bachlfab@gmail.com, Finn Lindgren finn.lindgren@gmail.com
Examples
fit <- bru(
~ 0 + x,
bru_obs(
y ~ .,
data = data.frame(x = 1:3, y = 1:3 + rnorm(3)),
tag = "A"
),
bru_obs(
y ~ .,
data = data.frame(x = 1:4, y = c(NA, NA, 3:4) + rnorm(4)),
tag = "B"
)
)
bru_index(fit)
#> [1] 1 2 3 4 5 6 7
bru_index(fit, "A")
#> [1] 1 2 3
bru_index(fit, "B")
#> [1] 4 5 6 7
bru_index(fit, c("B", "A"))
#> [1] 4 5 6 7 1 2 3
bru_index(fit, what = "missing")
#> [1] 4 5