@@ -314,45 +314,6 @@ See Figure 8 in [Gabry et al. (2019)](#gabry2019) for another example of using
314314
315315<br >
316316
317- ## Using PPC plots for prior predictive checking
318-
319- Although this vignette focuses on * posterior* predictive checking, the same
320- ` ppc_* ` functions can be used for ** prior** predictive checking as well. The
321- idea is the same: instead of passing draws from the posterior predictive
322- distribution as ` yrep ` , you pass draws from the ** prior** predictive
323- distribution. This can be useful for understanding the implications of your
324- priors before conditioning on the data (see Gabry et al. (2019) for more on
325- when prior predictive checks are useful).
326-
327- For example, with ** rstanarm** you can obtain prior predictive draws using
328- ` posterior_predict() ` on a model fit with ` prior_PD = TRUE ` :
329-
330- ``` {r prior-pd, eval=FALSE}
331- fit_prior <- stan_glm(
332- y ~ roach100 + treatment + senior,
333- offset = log(exposure2),
334- family = poisson,
335- data = roaches,
336- prior_PD = TRUE # sample from prior predictive only
337- )
338- yrep_prior <- posterior_predict(fit_prior)
339-
340- # use the same ppc_ functions with prior predictive draws
341- ppc_dens_overlay(y, yrep_prior[1:50, ])
342- ppc_stat(y, yrep_prior, stat = "mean")
343- ```
344-
345- If you want to examine the prior predictive distribution * without* comparing to
346- observed data, you can use the ` ppd_* ` functions (PPD = prior/posterior
347- predictive distribution) instead:
348-
349- ``` {r ppd-example, eval=FALSE}
350- ppd_dens_overlay(yrep_prior[1:50, ])
351- ppd_stat(yrep_prior, stat = "mean")
352- ```
353-
354- <br >
355-
356317## Providing an interface to bayesplot PPCs from another package
357318
358319The ** bayesplot** package provides the S3 generic function ` pp_check ` . Authors of
@@ -423,6 +384,45 @@ Several packages currently use this approach to provide an interface to
423384and [ ** brms** ] ( https://CRAN.R-project.org/package=brms ) packages.
424385
425386
387+ <br >
388+
389+ ## Using PPC plots for prior predictive checking
390+
391+ Although this vignette focuses on * posterior* predictive checking, the same
392+ ` ppc_* ` functions can be used for ** prior** predictive checking as well. The
393+ idea is the same: instead of passing draws from the posterior predictive
394+ distribution as ` yrep ` , you pass draws from the ** prior** predictive
395+ distribution. This can be useful for understanding the implications of your
396+ priors before conditioning on the data (see Gabry et al. (2019) for more on
397+ when prior predictive checks are useful).
398+
399+ For example, with ** rstanarm** you can obtain prior predictive draws using
400+ ` posterior_predict() ` on a model fit with ` prior_PD = TRUE ` :
401+
402+ ``` {r prior-pd, eval=FALSE}
403+ fit_prior <- stan_glm(
404+ y ~ roach100 + treatment + senior,
405+ offset = log(exposure2),
406+ family = poisson,
407+ data = roaches,
408+ prior_PD = TRUE # sample from prior predictive only
409+ )
410+ yrep_prior <- posterior_predict(fit_prior)
411+
412+ # use the same ppc_ functions with prior predictive draws
413+ ppc_dens_overlay(y, yrep_prior[1:50, ])
414+ ppc_stat(y, yrep_prior, stat = "mean")
415+ ```
416+
417+ If you want to examine the prior predictive distribution * without* comparing to
418+ observed data, you can use the ` ppd_* ` functions (PPD = prior/posterior
419+ predictive distribution) instead:
420+
421+ ``` {r ppd-example, eval=FALSE}
422+ ppd_dens_overlay(yrep_prior[1:50, ])
423+ ppd_stat(yrep_prior, stat = "mean")
424+ ```
425+
426426<br >
427427
428428## References
0 commit comments