| bmm_data_check | R Documentation |
Inspect whether your data is coded the way a bmmodel expects
before committing to Stan compilation and sampling. The function runs
the same validation pipeline that bmm() runs internally
(check_data() and check_formula()), but captures all errors,
warnings and messages instead of throwing them, and combines them with a
readable summary of:
the response variables, their observed values and the coding the model expects
the data columns each parameter formula uses, and how they are coded (factor levels, character vectors, numeric variables with few unique values)
the number of observations per design cell (crossing the grouping variables from random effects terms with the categorical predictors), flagging sparse or empty cells
model-specific diagnostics for common data mistakes (e.g. responses in
degrees rather than radians for circular models, or misplaced NA
values in the non-target features of set size varying designs).
These are provided by data_check_findings() methods, which new models
can extend
Problems are reported as findings rather than errors, so a single call shows everything that needs fixing at once.
The report covers the data and the formula only. It stops after
check_formula() and takes no prior argument, so a malformed custom
prior or a problem with the initial values is out of its reach and will
only surface when you call bmm().
bmm_data_check(formula, data, model, min_trials = 10)
formula |
An object of class |
data |
An object of class data.frame, containing data of all variables
used in the model. The names of the variables must match the variable names
passed to the |
model |
A description of the model to be fitted. This is a call to a
|
min_trials |
Numeric. Design cells with fewer observations are flagged
in the report. Defaults to 10. Ignored for models fit to aggregated data
(e.g. |
An object of class bmm_data_check with a print method. The object
is a list containing the summarized response, predictors and cells
information (including the full cell count table in $cells$counts), all
findings, and the captured results of the validation pipeline.
bmm(), check_data(), data_check_findings()
# three-parameter mixture model: radians check, NA padding of the
# non-target features across set sizes, trials per participant x set size
bmm_data_check(
bmf(kappa ~ 0 + set_size + (0 + set_size | ID), thetat ~ 0 + set_size),
data = oberauer_lin_2017,
model = mixture3p(
resp_error = "dev_rad",
nt_features = paste0("col_nt", 1:7),
set_size = "set_size"
)
)
# interference measurement model: additionally checks the NA padding
# of the non-target distances
bmm_data_check(
bmf(c ~ 1, a ~ 1, kappa ~ 1, s ~ 1),
data = oberauer_lin_2017,
model = imm(
resp_error = "dev_rad",
nt_features = paste0("col_nt", 1:7),
nt_distances = paste0("dist_nt", 1:7),
set_size = "set_size",
version = "full"
)
)
# signal discrimination model
bmm_data_check(
bmf(c ~ 0 + setsize, kappa ~ 0 + setsize),
data = zhang_luck_2008,
model = sdm(resp_error = "response_error")
)
# memory measurement model: response category counts as response variables
bmm_data_check(
bmf(c ~ 1 + (1 | ID), a ~ 1 + (1 | ID)),
data = oberauer_lewandowsky_2019_e1,
model = m3(
resp_cats = c("corr", "other", "npl"),
num_options = c("n_corr", "n_other", "n_npl"),
choice_rule = "simple",
version = "ss"
)
)
# diffusion decision model: reaction time plausibility and response coding
bmm_data_check(
bmf(drift ~ condition + (condition | ID)),
data = data_color_judgement_task,
model = ddm(rt = "rt", response = "response_correct")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.