combine_sources aggregates the proportions from multiple sources. Proportions are summed across posterior draws, since the source proportions are correlated.

combine_sources(jags.1, mix, source, alpha.prior = 1, groups)

Arguments

jags.1

rjags model object, output from run_model

mix

list, output from load_mix_data

source

list, output from load_source_data

alpha.prior

vector with length = n.sources, Dirichlet prior on p.global (default = 1, uninformative)

groups

list, which sources to combine, and what names to give the new combined sources. See example.

Value

combined, a list including:

  • combined$post: matrix, posterior draws with new source groupings

  • combined$source.new: list, original source list with modified entries for n.sources and source_names

  • combined$groups: (input) list, shows original and combined sources

  • combined$jags.1: (input) rjags model object

  • combined$source.old: (input) list of original source data

  • combined$mix: (input) list of original mix data

  • combined$prior.old: (input) prior vector on original sources

  • combined$prior.new: (output) prior vector on combined sources

Details

Note: Aggregating sources after running the mixing model (a posteriori) effectively changes the prior weighting on the sources. Aggregating uneven numbers of sources will turn an 'uninformative'/generalist prior into an informative one. Because of this, combine_sources automatically generates a message describing this effect and a figure showing the original prior, the effective/aggregated prior, and what the 'uninformative'/generalist prior would be if sources were instead grouped before running the mixing model (a priori).

See also

Examples

if (FALSE) { # first run mantis shrimp example # combine 6 sources into 2 groups of interest (hard-shelled vs. soft-bodied) # 'hard' = 'clam' + 'crab' + 'snail' # group 1 = hard-shelled prey # 'soft' = 'alphworm' + 'brittlestar' + 'fish' # group 2 = soft-bodied prey combined <- combine_sources(jags.1, mix, source, alpha.prior=alpha, groups=list(hard=c("clam","crab","snail"), soft=c("alphworm","brittlestar","fish"))) # get posterior medians for new source groupings apply(combined$post, 2, median) summary_stat(combined, meanSD=FALSE, quantiles=c(.025,.5,.975), savetxt=FALSE) }