posterior_predictive {cosimmr}R Documentation

Plot the posterior predictive distribution for a cosimmr run

Description

This function takes the output from cosimmr_ffvb and plots the posterior predictive distribution to enable visualisation of model fit. The simulated posterior predicted values are returned as part of the object and can be saved for external use

Usage

posterior_predictive(
  cosimmr_out,
  prob = 0.5,
  plot_ppc = TRUE,
  n_samples = 3600,
  sort_data = TRUE
)

Arguments

cosimmr_out

A run of the cosimmr model from cosimmr_ffvb.

prob

The probability interval for the posterior predictives. The default is 0.5 (i.e. 50pc intervals)

plot_ppc

Whether to create a bayesplot of the posterior predictive or not.

n_samples

The number of samples you wish to generate for y_pred. Defaults to 3600.

sort_data

Whether to order the data from lowest to highest predicted mean or not. Defaults to TRUE.

Value

plot of posterior predictives and simulated values

#' @author Emma Govan <emmagovan@gmail.com> Andrew Parnell

See Also

cosimmr_ffvb for creating objects suitable for this function

Examples


data(geese_data_day1)
cosimmr_1 <- with(
  geese_data_day1,
  cosimmr_load(
    formula = mixtures ~ c(1,2,3,2,1,2,3,2,1),
    source_names = source_names,
    source_means = source_means,
    source_sds = source_sds,
    correction_means = correction_means,
    correction_sds = correction_sds,
    concentration_means = concentration_means
  )
)

# Plot
plot(cosimmr_1)

# Print
cosimmr_1

# FFVB run
cosimmr_1_out <- cosimmr_ffvb(cosimmr_1)

# Prior predictive
post_pred <- posterior_predictive(cosimmr_1_out)


[Package cosimmr version 1.0.12 Index]