Skip to contents

"Workflow" version of run.meta.analysis.pft #' Run Bayesian meta-analysis for a single PFT (file-based wrapper)

Usage

run.meta.analysis.pft(
  pft,
  iterations,
  random = TRUE,
  threshold = 1.2,
  dbfiles,
  dbcon,
  use_ghs = TRUE,
  update = FALSE
)

Arguments

pft

(list) PFT list object, as defined in settings. Must include the following: outdir, name, posteriorid

iterations

(integer) Number of sampler iterations for MCMC analysis

random

(boolean; default = TRUE) Should random effects be used?

threshold

Gelman-Rubin convergence diagnostic (MGPRF) default = 1.2 following Bolker 2008 Ecological Models and Data in R

dbfiles

(character) directory where previous results are found

dbcon

(DBI connection object) BETY database connection object

use_ghs

(boolean; default = TRUE) If TRUE, do not exclude greenhouse data

update

(boolean; default = FALSE) If TRUE, replace existing posteriors with new ones

Value

The pft list (invisibly), or NA if no trait data are available. The returned pft list is a named list with the following elements:

name

(character) PFT name, e.g. "temperate.deciduous".

outdir

(character) Path to directory where output files are stored (trait data, priors, posteriors, MCMC samples).

posteriorid

(integer) Row ID of the posterior record in BETYdb's posteriors table.

constants

(named list, optional) Trait values to treat as fixed constants, bypassing the meta-analysis.

The function's primary outputs are communicated through files saved in pft$outdir.

Details

Upstream contract (reads from pft$outdir):

trait.data.Rdata

Named list of data frames produced by get.trait.data.pft. Loaded into trait_env$trait.data.

prior.distns.Rdata

Data frame of prior distributions produced by get.trait.data.pft. Loaded into prior_env$prior.distns.

File-based side effects (saved to pft$outdir):

trait.mcmc.Rdata

Contains trait.mcmc: a named list of mcmc.list objects (one per trait) with posterior MCMC samples from JAGS. Each element has columns beta.o (overall mean) and optionally sd.o (overall SD).

post.distns.MA.Rdata

Contains post.distns: a data frame with one row per trait and columns distn, parama, paramb, n summarizing the fitted posterior distribution.

post.distns.Rdata

Symlink to post.distns.MA.Rdata.

jagged.data.Rdata

Contains jagged.data: a named list of data frames (one per trait) formatted for use in the JAGS meta-analysis model (see jagify).

Downstream contract: The files trait.mcmc.Rdata and post.distns.Rdata are expected by get.parameter.samples (in PEcAn.uncertainty), which loads them to generate ensemble and sensitivity analysis samples.

Note: The core computation is performed by meta_analysis_standalone, which accepts and returns R objects directly — see its documentation for the pure-function interface.