Skip to contents

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".

Usage

data_check_findings(model, data, formula)

Arguments

model

A bmmodel object

data

The user supplied data.frame, before any transformations by check_data()

formula

The user supplied bmmformula

Value

A list of findings (possibly empty), each built with data_check_finding()

Examples

# 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())
}