pp_check.greta_mcmc_list: Posterior Predictive Checks for 'greta_mcmc_list' object

View source: R/pp_check.greta_mcmc_list.r

pp_check.greta_mcmc_listR Documentation

Posterior Predictive Checks for greta_mcmc_list object

Description

Perform posterior predictive checks with the help of the package bayesplot

Usage

## S3 method for class 'greta_mcmc_list'
pp_check(object, y, nsim = 10, type = "dens_overlay", ...)

Arguments

object

A greta_mcmc_list object obtained from the greta::mcmc function

y

A greta array of the response variable, see example

nsim

A numeric, the number of posterior simulation to draw, default is 10

type

A character string, the type of posterior predictive plot to draw. See PPC-overview for some options, or check the example below.

...

Further arguments passed to ppc_* functions, check the possibilities there.

Details

For a detailed explanation of each of the implemented ppc functions, see PPC-overview. Note that LOO and Discrete ppc_* function are not yet available for greta models.

Value

A ggplot object that can be further modified using the ggplot2 package.

Examples

## Not run: 
x <- runif(100, -2, 2)
y <- rnorm(100, 1 + 2 * x, 1)
# need the pass the response vector as greta array
y <- as_data(y)

intercept <- normal(0, 2)
slope <- normal(0, 1)
linpred <- intercept + slope * x
sd_res <- cauchy(0, 2, truncation = c(0, Inf))

distribution(y) <- normal(linpred, sd_res)
m <- model(intercept, slope, sd_res)
d <- mcmc(m, warmup = 10, n_samples = 10)

# default use
pp_check(d, y)
# check some options
pp_check(d, y, nsim = 4, type = "scatter_avg")
pp_check(d, y, type = "hist")
pp_check(d, y, type = "error_scatter") 

## End(Not run)


lionel68/greta.checks documentation built on July 30, 2022, 11:39 a.m.