This function performs a posterior predictive check for one or more Bayesian models by computing the mean and standard deviations of simulated predictions, comparing them to the observed outcome. It produces grouped histograms for each model.
compare_bayesm(
models,
ypredict = NULL,
data,
outcome,
intercept = NULL,
var.param = NULL
)Invisibly returns a list with two ggplot objects:
A ggplot object showing the distribution of simulated mean of the outcome across models.
A ggplot object showing the distribution of simulated standard deviations of the outcome across models.
A named list of fitted rstan models (objects of class stanfit).
Optional. A named list of posterior predictive matrices. Each matrix should have rows as posterior draws
and columns as data points. If not provided, predictions are computed internally. Must have the same names as models.
A data frame containing the predictor variables and the outcome used for model prediction.
A character string naming the outcome variable in data.
(Optional) A named list with the intercept parameter names for each model. Each entry should be a character string or NULL if no intercept is used. Must have the same names as models.
A named list mapping each model to a named character vector where each name is a variable in the data and the value is the name of the corresponding parameter/coefficient in the model.
Must have the same names as models. Required if ypredict is not provided.