combine_sources {MixSIAR} | R Documentation |
Combine sources from a finished MixSIAR model (a posteriori)
Description
combine_sources
aggregates the proportions from multiple sources.
Proportions are summed across posterior draws, since the source proportions
are correlated.
Usage
combine_sources(jags.1, mix, source, alpha.prior = 1, groups)
Arguments
jags.1 |
|
mix |
list, output from |
source |
list, output from |
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. |
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).
Value
combined
, a list including:
-
combined$post
: matrix, posterior draws with new source groupings -
combined$source.new
: list, originalsource
list with modified entries forn.sources
andsource_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
See Also
summary_stat
and plot_intervals
Examples
## Not run:
# 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)
## End(Not run)