greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
539 stars 63 forks source link

Separate out key parts of `check_*` functions in `test_posteriors.R` #723

Open njtierney opened 2 months ago

njtierney commented 2 months ago

For example, check_mvn_samples() calculates a scaled error variable, then checks to see if that is LTE some other value. These are two parts, one is effectively a statistical test, the other is the comparison, these should be separate components.

Similarly, check_samples() does:

  1. Compare MCMC samples of a distribution to the rnorm (using effective sample size)
  2. qqplot MCMC vs simulated values
  3. Do a kolmogorov smirnoff test of MCMC vs simulated values
  4. Compare if the KS test is below a threshold

These should be at least 3 parts:

  1. Calculate the MCMC vs simulated draws (possibly in a table?)
  2. qqplot function
  3. KS test function below a threshold

It might make it more verbose but it makes it easier to reason with when debugging