Skip to contents

This is the pure computation core extracted from get.parameter.samples(). It takes pre-loaded R objects as input and returns all computed samples directly, with no file I/O and no database calls.

Usage

get_parameter_samples(
  pft_names,
  prior_distns_list,
  trait_mcmc_list = NULL,
  ensemble.size = 1,
  ens.sample.method = "uniform",
  sa_quantiles = NULL,
  do_ensemble = TRUE,
  independent = TRUE
)

Arguments

pft_names

character vector of PFT names

prior_distns_list

list of data frames (one per PFT), each with columns: distn, parama, paramb, n. Row names are trait names.

trait_mcmc_list

list of trait MCMC results (one per PFT). Each element should be a named list of coda::mcmc.list objects, or NULL if no MCMC results exist for that PFT.

ensemble.size

integer. Number of runs in model ensemble.

ens.sample.method

character. One of "halton", "sobol", "torus", "lhc", "uniform".

sa_quantiles

numeric vector of quantiles for sensitivity analysis, or NULL to skip SA sampling.

do_ensemble

logical. Whether to generate ensemble samples.

independent

logical. TRUE means parameters were fitted individually (standard MA) and can be resampled independently. FALSE means they were fitted together (e.g. PDA) and correlations should be preserved.

Value

named list with five elements:

trait.samples

Named list by PFT, then by trait. Each leaf is a numeric vector of parameter samples.

sa.samples

Sensitivity analysis samples (list), or empty list if sa_quantiles is NULL.

ensemble.samples

Ensemble samples (list), or empty list if do_ensemble is FALSE.

runs.samples

Reserved for future use (empty list).

env.samples

Environmental samples (empty list, populated by downstream code if needed).

Details

For the original disk-based wrapper, see get.parameter.samples.

See also

get.parameter.samples for the backward-compatible wrapper that handles file I/O and database lookups.

Author

David LeBauer, Shawn Serbin, Istem Fer, Om Kapale

Examples

if (FALSE) { # \dontrun{
priors <- data.frame(
  distn  = "norm",
  parama = 20,
  paramb = 5,
  n      = 50,
  row.names = "SLA",
  stringsAsFactors = FALSE
)

result <- get_parameter_samples(
  pft_names         = "temperate.Hardwood",
  prior_distns_list = list(priors),
  ensemble.size     = 100,
  do_ensemble       = TRUE
)

str(result$trait.samples)
str(result$ensemble.samples)
} # }