combine_sources: Combine sources from a finished MixSIAR model (_a...

Description Usage Arguments Details Value See Also Examples

View source: R/combine_sources.R

Description

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

Usage

1
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.

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:

See Also

summary_stat and plot_intervals

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## 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)

MixSIAR documentation built on Oct. 23, 2020, 6:45 p.m.