Runs hierarchical meta-analysis of plant trait data

pecan.ma(
  trait.data,
  prior.distns,
  taupriors,
  j.iter,
  outdir,
  random = FALSE,
  overdispersed = TRUE,
  logfile = file.path(outdir, "meta-analysis.log)"),
  verbose = TRUE
)

Arguments

trait.data

list of data.frames, one per trait for which data is available, generated by call to PEcAn.DB::query.traits(), and post-processed by jagify().

prior.distns

data.frame of prior distributions generated by call to PEcAn.DB::query.priors()

taupriors

priors on variance parameters, can be scaled as needed with data mean

j.iter

number of MCMC samples

outdir

output directory

random

use random effects, FALSE by default

overdispersed

TRUE by default, if set to FALSE, data mean will be used as starting point for MCMC chains (use with caution)

logfile

Path to file for sinking meta analysis output. If NULL, only print output to console.

verbose

Logical. If TRUE (default), print progress messages.

data

data frame generated by jagify function with indexed values for greenhouse, treatment, and site (ghs, trt, site) as well as Y, SE, and n for each observation or summary statistic.

Value

four chains with 5000 total samples from posterior

Details

pecan.ma runs a hierarchical Bayesian meta-analytical model. This model combines prior information with data from studies on the particular species or group of interest. Data that is incorporated into the meta-analysis include the mean (Y), sample size (n), and precision (obs.prec). Where a set of data includes more than one level of treatment, comes from more than one site, or comes from both field and greenhouse studies, these variables are included as random (treatment, site) or fixed (greenhouse) effects. The pecan.ma function writes a model for each specific data set and prior using the write.ma.model() function to modify the ma.model.template.bug generic model.

Author

David LeBauer, Michael C. Dietze, Alexey Shiklomanov

Examples

if (FALSE) { # \dontrun{
  # Setup
  con <- PEcAn.DB::db.open(...)
  pft <- "temperate.Early_Hardwood"
  pft_id <- PEcAn.DB::db.query("SELECT id FROM pfts WHERE name = $1", con,
  values = list(pft))[[1]]
  traits <- c("SLA", "Vcmax")
  trait_string <- paste(shQuote(traits), collapse = ",")
  
  # Load traits and priors from BETY
  species <- PEcAn.DB::query.pft_species(pft, con = con)
  trait.data <- PEcAn.DB::query.traits(species[["id"]], c("SLA", "Vcmax"), con = con)
  prior.distns <- PEcAn.DB::query.priors(pft_id, trait_string, con = con)
  
  # Pre-process data
  jagged.data <- lapply(trait.data, PEcAn.MA::jagify)
  taupriors <- list(tauA = 0.01,
  tauB = c(SLA = 1000, Vcmax = 1000))
  result <- pecan.ma(jagged.data, prior.distns, taupriors,
                     j.iter = 5000, outdir = tempdir())
} # }