
Declare the observables of a bmm model for posterior predictive checks
Source:R/pp_observables.R
pp_observables.Rdpp_observables() returns the model's observable declaration used by
pp_check.bmmfit() when resp_var is specified, or NULL for models
that delegate fully to brms::pp_check(). pp_simulate() draws all
observables jointly from the posterior predictive distribution.
Arguments
- model
A
bmmodelobject.- prep
A
brmsprepobject frombrms::prepare_predictions().
Value
pp_observables() returns NULL for a model that delegates fully
to brms::pp_check(), or a list with elements observed (a named
character vector mapping observable names to brms standata slots),
checks (a named list of check definitions, each with a compute
closure, a label and a default plot type: a bayesplot ppc_* type
or bmm's "bars_binned") and, optionally, defaults and
y_placeholders (see Details). pp_simulate() returns a named list of
ndraws x nobs matrices, one per simulated observable.
Details
A pp_observables() method returns list(observed, checks):
observed: named character vector mapping observable names to slots of the brms standata ("Y","vreal1","vint1","trials","dec"). The observable mapped to"Y"is the default check.checks: named list of entries built by the internal.pp_observable()constructor. Eachcomputeclosure receives a named list keyed bynames(observed)and must be elementwise, so the identical closure producesyfrom length-N vectors andyrepfrom ndraws x N matrices.
Two optional elements serve observed data that holds placeholders rather
than observations, such as the summaries of an unused ezdm() boundary:
defaults: named vector giving, for observables whose slot a fit saved by an older bmm version lacks, the value to use for every observation.y_placeholders: a function of the fit's data that returnsTRUEif the"Y"slot holds placeholders. brms would plot them as data, sopp_check.bmmfit()withoutresp_varthen checks the observable mapped to"Y"itself.
A pp_simulate() method returns a named list of ndraws x nobs matrices
drawn jointly, typically through the internal .pp_simulate_joint() helper
around the model's r*() function. Simulating observables independently
would break their joint distribution (e.g. rt and response under the DDM).
Names not in observed are ignored; declared observables that are not
simulated (design quantities such as trial counts) are filled in from the
data.
Register exactly one method per model at the most general class level where the declaration is identical across versions.
These two generics are exported so that model methods defined outside bmm can be registered against them, but they are an internal developer interface documented for bmm's own model authors and carry no stability guarantee across releases.