bru_set_missing {inlabru} | R Documentation |
Set missing values in observation models
Description
Set all or parts of the observation model response data
to NA
, for example for use in cross validation (with bru_rerun()
)
or prior sampling (with bru_rerun()
and generate()
).
Usage
bru_set_missing(object, keep = FALSE, ...)
## S3 method for class 'bru'
bru_set_missing(object, keep = FALSE, ...)
## S3 method for class 'bru_obs_list'
bru_set_missing(object, keep = FALSE, ...)
## S3 method for class 'bru_obs'
bru_set_missing(object, keep = FALSE, ...)
Arguments
object |
A |
keep |
For For |
... |
Additional arguments passed on to the |
Details
For bru
and bru_obs_list
,
keep
must be either a single logical, which is expanded to a list,a logical vector, which is converted to a list,
an unnamed list of the same length as the number of observation models, with elements compatible with the
bru_obs
method, ora named list with elements compatible with the
bru_obs
method, and only the namedbro_obs
models are acted upon, i.e. the elements not present in the list are treated askeep = TRUE
.
E.g.: keep = list(b = FALSE)
sets all observations in model b
to missing,
and does not change model a
.
E.g.: keep = list(a = 1:4, b = -(3:5))
keeps only observations 1:4
of
model a
, marking the rest as missing, and sets observations 3:5
of model
b
to missing.
Examples
obs <- c(
A = bru_obs(y_A ~ ., data = data.frame(y_A = 1:6)),
B = bru_obs(y_B ~ ., data = data.frame(y_B = 11:15))
)
bru_response_size(obs)
lapply(
bru_set_missing(obs, keep = FALSE),
function(x) {
x[["response_data"]][["BRU_response"]]
}
)
lapply(
bru_set_missing(obs, keep = list(B = FALSE)),
function(x) {
x[["response_data"]][["BRU_response"]]
}
)
lapply(
bru_set_missing(obs, keep = list(1:4, -(3:5))),
function(x) {
x[["response_data"]][["BRU_response"]]
}
)