posterior_predictive: Plot the posterior predictive distribution for a simmr run

Description Usage Arguments Examples

View source: R/posterior_predictive.simmr_output.R

Description

This function takes the output from simmr_mcmc 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

1
posterior_predictive(simmr_out, group = 1, prob = 0.5, plot_ppc = TRUE)

Arguments

simmr_out

A run of the simmr model from simmr_mcmc

group

Which group to run it for (currently only numeric rather than group names)

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
data(geese_data_day1)
simmr_1 <- with(
  geese_data_day1,
  simmr_load(
    mixtures = mixtures,
    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(simmr_1)

# Print
simmr_1

# MCMC run
simmr_1_out <- simmr_mcmc(simmr_1)

# Prior predictive
post_pred <- posterior_predictive(simmr_1_out)

## End(Not run)

Example output

Loading required package: R2jags
Loading required package: rjags
Loading required package: coda
Linked to JAGS 4.3.0
Loaded modules: basemod,bugs

Attaching package:R2jagsThe following object is masked frompackage:coda:

    traceplot

Loading required package: ggplot2
This is a valid simmr input object with 9 observations, 2 tracers, and 4 sources.
The source names are: Zostera, Grass, U.lactuca, Enteromorpha.
The tracer names are: d13C_Pl, d15N_Pl.

module glm loaded
Compiling model graph
   Resolving undeclared variables
   Allocating nodes
Graph information:
   Observed stochastic nodes: 18
   Unobserved stochastic nodes: 6
   Total graph size: 128

Initializing model

Compiling model graph
   Resolving undeclared variables
   Allocating nodes
Graph information:
   Observed stochastic nodes: 18
   Unobserved stochastic nodes: 24
   Total graph size: 146

Initializing model

simmr documentation built on Feb. 27, 2021, 5:05 p.m.