Posterior predictive check
posterior_predictive_check.RdCompares the observed outcome proportions of each arm with those of data replicated from the fitted model. The replicated data are simulated in Stan from each posterior draw, with the same number of mosquitoes per observation as in the data. Available for the basic and semifield models.
Usage
posterior_predictive_check(
stan_fit,
data,
n_draws = 200,
probs = c(0.025, 0.975)
)Arguments
- stan_fit
A stanfit object from
fit_ento_model, fitted withsave_y_rep = TRUE.- data
The data used to fit the model, same rows in the same order: formatted EHT data for the basic model, or the list with y0 and y1 for the semifield model (arms labelled "Control" and "Intervention"; the trap outcome T is left out when there is no trap).
- n_draws
Integer. Number of posterior draws to use (random subset).
- probs
Numeric vector. Quantiles of the replicated proportions. Default is c(0.025, 0.975) for a 95% interval.
Value
A list with:
summary: A tibble with one row per arm and outcome: treatment, outcome (UA, UD, FA, FD for the basic model; H1, H2, H3, H4, T, L for the semifield model), observed proportion, median, lower and upper quantiles of the replicated proportions, and p_value, the share of replicates greater than or equal to the observed proportion (values close to 0 or 1 indicate that the model does not reproduce the data)
replicates: A tibble with the replicated proportion of each draw, arm and outcome
Both include vector_control_product if the data have this column.
Examples
if (FALSE) { # \dontrun{
fit <- fit_ento_model(eht_data, model_type = "basic", save_y_rep = TRUE)
ppc <- posterior_predictive_check(fit, eht_data)
ppc$summary
plot_posterior_predictive(ppc)
} # }