plot_trace: Creates trace plots of specified parameters showing the...

Description Usage Arguments Value Author(s) Examples

View source: R/plot_trace.R

Description

Takes the MCMC object returned from a split and produces trace_plots for the listed parameters. It shows a separate line on the plot for each chain and also shows the value of Rhat

Usage

1
2
3
4
5
6
7
plot_trace(
  title = " ",
  results = NULL,
  parms_to_plot = NULL,
  nrow = 2,
  ncol = 2
)

Arguments

title

A character string used for a title on reports and graphs

results

The MCMC object containing the results from the call to JAGS

parms_to_plot

A character vector of names of parameters to plot. These must match exactly to the parameter names used in the simulation.

ncol, nrow

How many plots to put on a page (number of rows and columns)

Value

List of ggplot2 objects using facet_wrap_paginate (...., page=...) with each element of the list corresponding to one page of the plot.

Author(s)

Bonner, S.J. sbonner6@uwo.ca and Schwarz, C. J. cschwarz.stat.sfu.ca@gmail.com.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
# Create trace plots of the logitP parameters
# 
# Trace plots of logitP
varnames <- names(results$sims.array[1,1,])  # extract the names of the variables 
trace.plot <- plot_trace(title=title, 
                         results=results, 
                         parms_to_plot=varnames[grep("^logitP", varnames)])
if(save.output.to.files){
  pdf(file=paste(prefix,"-trace-logitP.pdf",sep=""))
  plyr::l_ply(trace.plot, function(x){plot(x)})
  dev.off()
}

## End(Not run) % end of dontrun

BTSPAS documentation built on Oct. 25, 2021, 9:07 a.m.