compile_rjMCMC: Dose-response curves

View source: R/compile_rjMCMC.R

compile_rjMCMCR Documentation

Dose-response curves

Description

Compute dose-response functions from a fitted rjMCMC model.

Usage

compile_rjMCMC(
  rj.object,
  phase = 1,
  by.model = FALSE,
  model.rank = 1,
  covariate = NULL,
  covariate.values = NULL,
  species = NULL,
  credible.intervals = 95,
  npts = 20
)

Arguments

rj.object

Input rjMCMC object of class rjtrace, as returned by trace_rjMCMC.

phase

Dose-response functional form: monophasic (1) or biphasic (2).

by.model

Logical. If TRUE, the function subsets posterior parameter estimates to produce separate dose-response curves for each candidate model.

model.rank

Rank of the model to generate curves for when by.model = TRUE.

covariate

Covariate name. This argument can be used to generate dose-response curves for specific contextual covariates, conditioned on the species (group) given by species.

covariate.values

A vector of values for which dose-response curves are required. Only valid for continuous covariates.

species

Species name.

credible.intervals

Credible intervals. Must be a integer vector in (0, 100]. Defaults to 5-95% in 5% increments.

npts

Number of quadrature points to use to integrate out the random effects when computing dose-response curves for biphasic models. Defaults to 20.

Value

A list object of class dose_response.

Author(s)

Phil J. Bouchet

See Also

run_rjMCMC plot.dose_response

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 dose-response functions
doseR <- compile_rjMCMC(rj.trace)

## End(Not run)

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