View source: R/predictive_checks_outcomes.R
| check_dyad_outcomes | R Documentation |
A model should reproduce the distribution of the observed outcomes. This
check compares the observed outcome distribution and summaries (response SD
after subtracting predictions, largest absolute deviation from prediction,
number of zeros) with complete datasets from
simulate_dyad_responses().
This helps identify mismatches in the model's assumptions, such as the
distribution family, dispersion, or zero inflation.
For PIT residual patterns, also run check_dyad_residuals() with the same
simulations.
For guidance on how to read the plots, see plot.dyadMLM_outcome_check().
check_dyad_outcomes(
simulations,
dyad = NULL,
role = NULL,
member = NULL,
plot = TRUE,
ask = NULL,
panels = TRUE,
data = NULL
)
simulations |
An object from |
dyad |
Dyad ID column, with or without quotes. Required when |
role |
Role column, with or without quotes, such as gender. |
member |
Person ID column, with or without quotes. Required with |
plot |
If |
ask |
Whether to pause between figures on an interactive device.
|
panels |
If |
data |
The unchanged data used to fit the model. Supply it when the
columns you name (such as |
Invisibly returns a dyadMLM_outcome_check list with role-specific
summary matrices and outcome distributions in compositions. Matrices have
one column per dataset (observed first, then all simulated). Optionally,
suppress plotting with plot = FALSE and draw the saved result later with
plot(result), which also takes ask and panels.
Complete simulated datasets keep the fitted partner and time dependence and
any modeled differences in variability between roles. Unlike DHARMa's default
(since version 0.5.0), simulations redraw all random effects. Dyadic models
often fix the residual variance near zero (dispformula = ~ 0) and model the
partners' residual variances and covariance as random effects. If held
fixed, these random effects would reproduce the data almost exactly.
Parameters stay fixed at their fitted values, so parameter uncertainty is not
included. These are descriptive checks, not significance tests, and
differ from DHARMa's plots and tests (see the
distribution-checks article).
They do not directly assess serial correlation.
Predicted outcomes are mean predictions with random effects set to zero (see
simulate_dyad_responses()). The checks use the same fitted rows and
families as simulate_dyad_responses() and weight all observations equally.
Check partner correlations with check_partner_dependence().
check_dyad_residuals(), check_partner_dependence()
example_data <- prepare_dyad_data(
dyads_cross,
dyad = coupleID,
member = personID,
model_types = "none",
seed = 123
)
# Exchangeable dyads: the two random-effect blocks represent the partners'
# residual variances and covariance.
model <- glmmTMB::glmmTMB(
closeness ~ gender + provided_support +
us(1 | coupleID) + us(0 + .member_contrast_arbitrary | coupleID),
dispformula = ~ 0,
data = example_data
)
simulations <- simulate_dyad_responses(
model,
nsim = 100, # Low for a quick example. Use at least 1,000.
seed = 123
)
check_dyad_outcomes(
simulations,
dyad = coupleID,
role = gender,
ask = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.