View source: R/bru.inference.R
| bru_set_missing | R Documentation |
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()).
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, ...)
object |
A |
keep |
For For |
... |
Additional arguments passed on to the |
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, or
a named list with elements compatible with the bru_obs method,
and only the named bro_obs models are acted upon, i.e. the elements
not present in the list are treated as keep = 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.
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"]]
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.