plot.rjtrace: Diagnostic plots

View source: R/plot.rjtrace.R

plot.rjtraceR Documentation

Diagnostic plots

Description

Generate trace, density, and autocorrelation plots from an rjtrace object.

Usage

## S3 method for class 'rjtrace'
plot(
  rj.obj,
  param.name = NULL,
  phase = NULL,
  type = "both",
  adjust = 2,
  gvals = NULL,
  priors = NULL,
  covariates.incl = FALSE,
  autocorr = FALSE,
  individual = TRUE
)

Arguments

rj.obj

rjMCMC trace object of class rjtrace.

param.name

Parameter name(s). Defaults to NULL, which returns plots for all parameters in the model.

phase

Integer. If used, will only generate plots for the parameters of the monophasic (1) or biphasic (2) model.

covariates.incl

Logical. If TRUE, the trace is filtered to only retain posterior estimates obtained when the contextual covariates were included in the model. Only relevant when covariate.select = TRUE in configure_rjMCMC.

autocorr

Logical. Whether to output chain autocorrelation plots.

individual

Logical. If TRUE, separate density lines will be plotted for each chain. If FALSE, one density line will be plotted for all chains.

Details

Adapted from Casey Youngflesh's function MCMCtrace.

Author(s)

Phil J. Bouchet

See Also

run_rjMCMC trace_rjMCMC

Examples

## Not run: 
library(espresso)

# Import the example data, excluding species with sample sizes < 5
# and considering the sonar covariate
mydat <- read_data(file = NULL, min.N = 5, covariates = "sonar") 
summary(mydat)

# Configure the sampler
mydat.config <- configure_rjMCMC(dat = mydat,
                                 model.select = TRUE,
                                 covariate.select = FALSE,
                                 function.select = FALSE,
                                 n.rep = 100)
summary(mydat.config)

# Run the reversible jump MCMC
rj <- run_rjMCMC(dat = mydat.config,
                 n.chains = 2,
                 n.burn = 100,
                 n.iter = 100,
                 do.update = FALSE)

# Burn and thin
rj.trace <- trace_rjMCMC(rj.dat = rj)

# Get density and trace plots
plot(rj.trace)

## End(Not run)

pjbouchet/espresso documentation built on July 27, 2024, 12:31 p.m.