Skip to contents

This function takes in a model object, the observed data, and the configuration file used to produce the real-data stan data object.

If running a posterior-predictive analysis, it then fits the model, extracts generated quantities from some number of those fits, and runs new analyses on the simulated data. Lastly it returns summaries of estimation performance.

If running prior-predictive analyses, it runs under the prior to get the joint prior distribution. Then it extracts generated quantities from some number of those fits, and runs new analyses on the simulated data. Lastly it returns summaries of estimation performance.

Usage

posterior_predictive_analysis(
  model,
  real_data,
  config,
  draw = NULL,
  real_data_fit = NA,
  ci_width = 0.89,
  mclapply_cores = NA,
  under_prior = FALSE,
  ...
)

Arguments

model

a CmdStanModel object defining the model

real_data

observed data, formated for stan

config

the output of get_config_vals()

draw

vector, which draws from the MCMC object do we want to run PPS analyses for? If NULL, runs one analysis per sample. This can take a long time and a lot of space!

real_data_fit

CmdStanMCMC object, optional argument providing a previous real-data model fit

mclapply_cores

integer specifying number of threads to use for posterior-predictive-analysis-level parallelization, separate from stan parallelization

under_prior

boolean, if TRUE prior-predictive analysis is run, not posterior

...

further arguments passed to model$sample(), e.g. # chains

pps_mcmc_fits

list of CmdStanMCMC objects, optional argument providing previously-run pps analyses (for re-summarizing)

Value

a list, each of which is a list of formatted stan data