Skip to contents

This function defines the jagsmodel script to call based on the selected distribution. It also defines the initial values and variables to monitor.

Usage

setup_likelihood(
  distribution,
  data,
  manual_prior = FALSE,
  prior_list = NULL,
  random = FALSE
)

Arguments

distribution

Any of 'Normal', 'Gamma', 'Skewed', 'Lognormal', or 'Beta'.

data

Emissions data from either the best source or top performers, must have a column named emissions.

manual_prior

Default is FALSE, priors are uninformative and calculated from range of emissions data. if TRUE priors should be specified manually in prior_list.

prior_list

Optional list of stats::dunif() upper and lower bounds for prior distributions. For 'Normal' they are ordered c(sd_low, sd_high, mean_low, mean_high). For 'Lognormal' they are ordered c(log_sd_low, log_sd_high, log_mean_low, log_mean_high). For 'Skewed' they are ordered c(omega_low, omega_high, xi_low, xi_high, alpha_low, alpha_high). For 'Gamma'they are orderedc(rate_low, rate_high, shape_low, shape_high). For 'Beta'they are orderedc(alpha_low, alpha_high, beta_low, beta_high)`.

random

Default is FALSE where random seeds are defined via .RNG.name and .RNG.seed so JAGS runs will be exactly reproducible. Changing to TRUE will use random values for .RNG.name and .RNG.seed instead.

Value

Object model_code, which is a string for the written R script that JAGS can call, par_list which is the list of parameters traced while running the JAGS model, dat_inits which is a list of initial parameter values and random seeds for 3 chains, and the distribution used in likelihood model.