Ex 5: Isopod

Here we step through the Isopod Example using the script version of MixSIAR. For a demonstration using the GUI version, see the MixSIAR Manual. For a thorough walkthrough of how to use MixSIAR in a script, see the Wolves Example, which provides more commentary and explanation.

For a clean, runnable .R script, look at mixsiar_script_isopod.R in the example_scripts folder of the MixSIAR package install:

mixsiar.dir <- find.package("MixSIAR")

You can run the isopod example script directly with:


Isopod Example

The Isopod Example is from Galloway et al. 2014 and demonstrates MixSIAR applied to an 8-dimensional fatty acid dataset. Here the mixture data are isopod polyunsaturated fatty acid (PUFA) profiles, with 5 replicates at each of 6 sites in Puget Sound, WA:

Here we treat Site as a random effect. This makes sense if we are interested in the overall population and think of Site as a nuisance factor. Fitting Site as a fixed effect would make more sense if we were interested specifically in the diet at each Site, as opposed to the overall population diet and variability between Sites. This differs from the analysis in Galloway et al. 2014.

Fatty acid data greatly increase the number of biotracers beyond the typical 2 stable isotopes, d13C and d15N, which gives the mixing model power to resolve more sources. We caution, however, that using fatty acid data is not a panacea for the “underdetermined” problem (# sources > # biotracers + 1). As the number of sources increases, the “uninformative” prior \((\alpha=1)\) has greater influence, even if there are many more biotracers than sources. See the Cladocera Example prior with 7 sources and 22 biotracers.

Load MixSIAR package

Load mixture data

See ?load_mix_data for details.

The isopod consumer data has 1 covariate (factors="Site"), which we fit as a random effect (fac_random=TRUE). “Site” is not nested within another factor (fac_nested=FALSE). There are no continuous effects (cont_effects=NULL).

Load source data

See ?load_source_data for details.

We do not have any fixed/random/continuous effects or concentration dependence in the source data (source_factors=NULL, conc_dep=FALSE). We only have source means, SD, and sample size—not the original “raw” data (data_type="means").

Load discrimination data

See ?load_discr_data for details.

Note that Galloway et al. 2014 conducted feeding trials to create a “resource library”. In the mixing model, the sources are actually consumers fed exclusively each of the sources. This allowed them to set the discrimination = 0 (see isopod_discrimination.csv).

Plot data

This is your chance to check:

When there are more than 2 biotracers, MixSIAR currently plots every pairwise combination. Here, that means \({8 \choose 2} = 28\) plots are produced. In the future, MixSIAR will offer non-metric multidimensional scaling (NMDS) plots for these cases.

Plot prior

Define your prior, and then plot using “plot_prior”

Write JAGS model file

In the Isopod Example we demo the “Residual only” error option. The differences between “Residual * Process”, “Residual only”, and “Process only” are explained in Stock and Semmens (2016).

Run model

First use run = "test" to check if 1) the data are loaded correctly and 2) the model is specified correctly:

After a test run works, increase the MCMC run to a value that may converge:

Analyze diagnostics and output

See ?output_JAGS for details.

Since we fit Site as a random effect, we can make inference on diet at the overall population level (p.global, posterior plot) as well as at individual sites (Site CP, posterior plot).