Compute and plot posterior predictive p-value (Bayesian p-value) from samples of a distribution. The simulations and observations are first summarised into a test statistics, then the test statistic of the observations is compared to the test statistic of the empirical distribution.
post_pred_pval(
yrep,
y,
test_statistic = mean,
alternative = c("two.sided", "less", "greater"),
plot = FALSE
)
Matrix of posterior replications with rows corresponding to samples and columns to simulated observations.
Vector of observations.
Function of the test statistic to compute the p-value for.
Indicates the alternative hypothesis: must be one of "two.sided"
, "greater"
or "less"
.
Whether to output a plot visualising the distribution of the test statistic.
List containing the p-value and (optionally) a ggplot.