| data_check_findings | R Documentation |
Called by bmm_data_check() to collect model-specific
diagnostics of common data coding mistakes. Like check_data(), methods
dispatch over the model class chain from general to specific, and every
method should concatenate its own findings with NextMethod(). Each
finding is a list with elements severity ("warning" or "note") and
message. Unlike check_data(), these diagnostics never throw - they
only describe likely problems, so a report can always be produced.
Defining a method is entirely optional: the default method returns an
empty list, and bmm_data_check() produces its full generic report for
models without any method. Add one only when a model has a common data
mistake that the hard checks in check_data() deliberately tolerate - a
mistake check_data() already warns about needs no method, because
bmm_data_check() captures that warning and reports it under
"Hard checks".
data_check_findings(model, data, formula)
model |
A |
data |
The user supplied data.frame, before any transformations by
|
formula |
The user supplied |
A list of findings (possibly empty), each built with
data_check_finding()
data_check_finding(), bmm_data_check()
# a method for a model whose check_data() tolerates unnormalized weights
data_check_findings.my_model <- function(model, data, formula) {
weights <- data[[model$other_vars$weights]]
findings <- list()
if (!isTRUE(all.equal(sum(weights), 1))) {
findings <- list(data_check_finding(
"warning",
glue::glue("The weights sum to {sum(weights)} rather than 1.")
))
}
c(findings, NextMethod())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.