Bayesian Mixing Models in R

Creates and runs Bayesian mixing models to analyze biological tracer data (i.e. stable isotopes, fatty acids), which estimate the proportions of source (prey) contributions to a mixture (consumer). 'MixSIAR' is not one model, but a framework that allows a user to create a mixing model based on their data structure and research questions, via options for fixed/ random effects, source data types, priors, and error terms. 'MixSIAR' incorporates several years of advances since 'MixSIR' and 'SIAR', and includes both GUI (graphical user interface) and script versions.


cran version rstudio mirror downloads DOI

MixSIAR is an R package that helps you create and run Bayesian mixing models to analyze biotracer data (i.e. stable isotopes, fatty acids), following the MixSIAR model framework. Both graphical user interface (GUI) and script versions are available.

MixSIAR represents a collaborative coding project between the investigators behind MixSIR, SIAR, and IsoSource: Brice Semmens, Brian Stock, Eric Ward, Andrew Parnell, Donald Phillips, and Andrew Jackson.

MixSIAR incorporates several years of advances in Bayesian mixing model theory since MixSIR and SIAR, currently:

  • Any number of biotracers (examples with 1 isotope, 2 isotope, 8 fatty acids, and 22 fatty acids)
  • Source data fit hierarchically within the model
  • Source data by categorical covariate (e.g. sources by Region)
  • Categorical covariates (up to 2, choice of modeling as random or fixed effects, either nested or independent)
  • Continuous covariate (up to 1)
  • Error structure options with covariance (Residual * Process, Residual only)
  • Concentration dependence
  • Plot and include “uninformative”/generalist or informative priors
  • Fit multiple models and compare relative support using LOO/WAIC weights

The script version is easier to install and better for repeated analysis. If you want the script version only (no GUI):

  1. Download and install/update R.

  2. Download and install JAGS.

  3. Open R and run:

install.packages("MixSIAR")
library(MixSIAR)

The vignettes can be accessed via:

browseVignettes("MixSIAR")

There is a more extensive user manual included in the package install. To find the directory location on your computer:

find.package("MixSIAR")

The manual is also available from the GitHub site here.

FULL INSTALL (with GUI)

Getting the GUI running is more work, but can be a nice introduction to MixSIAR. The install instructions are platform-specific:

Windows

  1. Download and install/update R.

  2. Download and install JAGS.

  3. Open R.

  4. Install GTK+ dependent packages:

    install.packages(c("gWidgets", "RGtk2", "gWidgetsRGtk2"))
    
  5. Load RGtk2. You will be prompted to install GTK+. Follow the automatic prompts and do not interrupt the GTK+ installation!:

    library(RGtk2)
    
  6. Restart R and run:

    install.packages("MixSIAR", dependencies=TRUE)
    
  7. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

There is an extensive user manual included in the package install. To find the directory location on your computer:

find.package("MixSIAR")

Alternatively, you can download the manual from the GitHub site here.

Mac OS X

  1. Download and install/update R.

  2. Download and install JAGS.

  3. Open R.

  4. Install GTK+ dependent R packages:

    install.packages(c("gWidgets", "RGtk2", "gWidgetsRGtk2"))
    
  5. Close R.

  6. Download and install the newest GTK+ framework.

  7. Install the latest X11 application, xQuartz.

  8. Open R and run:

    install.packages("MixSIAR", dependencies=TRUE)
    
  9. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

There is an extensive user manual included in the package install. To find the directory location on your computer:

find.package("MixSIAR")

Alternatively, you can download the manual from the GitHub site here.

Linux

  1. Download and install/update R.

  2. Download and install JAGS. Or, from the terminal: sudo apt-get install jags r-cran-rjags.

  3. Download and install GTK+ framework. From the terminal: sudo apt-get install libgtk2.0-dev.

  4. Check if GTK+ is installed correctly. Open R, install and load the RGtk2 package with:

    install.packages("RGtk2")
    library(RGtk2)
    
  5. Install MixSIAR:

    install.packages("MixSIAR", dependencies=TRUE)
    
  6. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

There is an extensive user manual included in the package install. To find the directory location on your computer:

find.package("MixSIAR")

Alternatively, you can download the manual from the GitHub site here.

FEEDBACK PLEASE!

This software has been improved by the questions, suggestions, and bug reports of the user community. If you have a comment, ideally use the Issues page. You can also post to the SIAR facebook group or shoot me an email ([email protected]).

ON CITING MixSIAR:

If you use MixSIAR results in publications, please cite the MixSIAR manual as (similar to how you cite R):

The primary citation for Bayesian mixing models (MixSIR):

Moore, J. W., & Semmens, B. X. (2008). Incorporating uncertainty and prior information into stable isotope mixing models. Ecology Letters, 11(5), 470-480.

If you are using the residual error term (SIAR):

Parnell, A. C., Inger, R., Bearhop, S., & Jackson, A. L. (2010). Source partitioning using stable isotopes: coping with too much variation. PLoS One, 5(3), e9672.

If you are using a hierarchical structure/random effects:

Semmens, B. X., Ward, E. J., Moore, J. W., & Darimont, C. T. (2009). Quantifying inter-and intra-population niche variability using hierarchical Bayesian stable isotope mixing models. PLoS One, 4(7), e6187.

If you are using continuous effects:

Francis, T. B., Schindler, D. E., Holtgrieve, G. W., Larson, E. R., Scheuerell, M. D., Semmens, B. X., & Ward, E. J. (2011). Habitat structure determines resource use by zooplankton in temperate lakes. Ecology letters, 14(4), 364-372.

If you are using source fitting:

Ward, E. J., Semmens, B. X., & Schindler, D. E. (2010). Including source uncertainty and prior information in the analysis of stable isotope mixing models. Environmental science & technology, 44(12), 4645-4650.

For a detailed description of the math underlying these models, see:

Parnell, A. C., Phillips, D. L., Bearhop, S., Semmens, B. X., Ward, E. J., Moore, J. W., Jackson, A. L., Grey, J., Kelley, D. J., & Inger, R. (2013). Bayesian stable isotope mixing models. Environmetrics, 24, 387-399.

For an explanation of the error structures ("Process only" vs. "Resid only" vs. "Process * Resid"), see:

Stock, B. C., & Semmens, B. X. (2016). Unifying error structures in commonly used biotracer mixing ­models. Ecology, 97(10), 2562–2569.

Finally... yes, a paper introducing MixSIAR is in the works and will be forthcoming shortly.

INSTALLATION (GitHub):

If for some reason you can't install using install.packages, the GitHub version is another option.

Windows (GitHub)

  1. Download and install/update R.

  2. Download and install JAGS.

  3. (Optional) If you want to build the vignettes, install pandoc or R Studio.

  4. Open R.

  5. Install GTK+ dependent packages:

    install.packages(c("gWidgets", "RGtk2", "gWidgetsRGtk2", "devtools"))
    
  6. Load RGtk2. You will be prompted to install GTK+. Follow the automatic prompts and do not interrupt the GTK+ installation!:

    library(RGtk2)
    
  7. Restart R and run:

    library(devtools)
    devtools::install_github("brianstock/MixSIAR",
                             dependencies = TRUE, 
                             build_vignettes = TRUE) # FALSE if no pandoc/R Studio
    
  8. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

Mac OS X (GitHub)

  1. Download and install/update R.

  2. Download and install JAGS.

  3. (Optional) If you want to build the vignettes, install pandoc or R Studio.

  4. Open R.

  5. Install GTK+ dependent R packages:

    install.packages(c("gWidgets", "RGtk2", "gWidgetsRGtk2", "devtools"))
    
  6. Close R.

  7. Download and install the newest GTK+ framework.

  8. Install the latest X11 application, xQuartz.

  9. Open R and run:

    library(devtools)
    devtools::install_github("brianstock/MixSIAR",
                             dependencies = TRUE, 
                             build_vignettes = TRUE) # FALSE if no pandoc/R Studio
    
  10. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

Linux (GitHub)

  1. Download and install/update R.

  2. Download and install JAGS. Or, from the terminal: sudo apt-get install jags r-cran-rjags.

  3. Download and install GTK+ framework. From the terminal: sudo apt-get install libgtk2.0-dev.

  4. (Optional) If you want to build the vignettes, install pandoc or R Studio.

  5. Check if GTK+ is installed correctly. Open R, install and load the RGtk2 package with:

    install.packages("RGtk2")
    library(RGtk2)
    
  6. Install and load devtools, then install MixSIAR:

    install.packages("devtools")
    library(devtools)
    devtools::install_github("brianstock/MixSIAR",
                             dependencies = TRUE, 
                             build_vignettes = TRUE) # FALSE if no pandoc and pandoc-citeproc
    
  7. Load MixSIAR and run GUI:

    library(MixSIAR)
    mixsiar_gui()
    

News

MixSIAR 3.1.10

MINOR IMPROVEMENTS

  • fixed minor mistakes in manual (new example datasets table)
  • scale mix and source tracer data (so can always use same priors regardless of scale of data)
  • update compare_models to work with loo 2.0.0

MixSIAR 3.1.9

Nothing changed, just trying to get new Zenodo DOI (3.1.8 failed)

MixSIAR 3.1.8

MINOR IMPROVEMENTS

  • updated manual
  • new example: alligator diet, model comparison table with LOO/WAIC weights
  • new example: mantis shrimp diet, informative priors + combining sources
  • new function 'compare_models' to perform model selection based on LOO/WAIC weights, via 'loo' package
  • new function 'combine_sources' to aggregate sources a posteriori
  • new function 'summary_stat' to print summary of posterior after combining sources
  • new function 'plot_intervals' to plot CI of posterior after combining sources

MixSIAR 3.1.7.9001

MINOR IMPROVEMENTS

  • Removed attach.jags call (now directly use jags.1$BUGSoutput$sims.list)
  • Added epsilon (multiplicative error term) estimates to output (summary stats, posterior plots)

BUG FIX

  • Fixed bug #129 by using MCMCpack::rdirichlet instead of compositions::rDirichlet.rcomp
  • Small changes to pass R CMD check

MixSIAR 3.1.7.9000

MINOR IMPROVEMENTS

  • Improved continuous effect output plots: 1) added 95% CI shading, 2) plot each level of fixed effect
  • Fixed bug with 1FE + 1RE: empty levels Heidelberger diagnostic (#100)
  • Fixed bug with 1FE + 1RE: posterior density plots saved over themselves
  • Added return value for output_JAGS function: now returns p.both if 1FE + 1RE

VERY MINOR IMPROVEMENTS

  • Added check/error message: if sources by factor, sources must match for all factor levels
  • Updated CITATION and manual

MixSIAR 3.1.7 (2016-08-15)

MINOR IMPROVEMENTS

  • Changed resid.prop prior from dchisqr(3) to dunif(0,20)

VERY MINOR IMPROVEMENTS

  • Updated install instructions in README (install.packages)
  • Fixed error in Cladocera vignette (process vs. resid error)
  • Fixed link to manual to CRAN page (DESCRIPTION file)

MixSIAR 3.1.6 (2016-06-24)

VERY MINOR IMPROVEMENTS

  • CRAN submission
  • added files for CRAN submission (cran-comments.md, NEWS.md)
  • fixed broken links found when checking for CRAN submission

MixSIAR 3.1.5 (2016-06-21)

VERY MINOR IMPROVEMENTS

  • Changed "Isotopes" to "Tracers" in GUI

MixSIAR 3.1.4 (2016-06-21)

BUG FIX

  • Fixed bug #72 by using utils::globalVariables(), created when making changes to pass R CMD check for CRAN submission

MixSIAR 3.1.3 (2016-06-01)

MINOR IMPROVEMENTS

  • Tests via testthat package (see "tests/testthat" folder)
  • Changes to pass R CMD check for submission to CRAN

MixSIAR 3.1.2 (2016-03-16)

MINOR IMPROVEMENTS

  • download latest release by default (instead of master)
  • updated citation info

MixSIAR 3.1.1 (2016-03-11)

NEW FEATURES

  • Added vignettes for script examples, see browseVignettes("MixSIAR")

MINOR IMPROVEMENTS

  • Tested package install on Windows, Mac, Linux
  • Revised install instructions
  • Couple minor bug fixes
  • Revised manual

MixSIAR 3.1.0 (2016-03-09)

NEW FEATURES

  • Converted to R package structure, so can now run MixSIAR with:

library(MixSIAR) mixsiar_gui()

MixSIAR 3.0.2 (2015-11-19)

BUG FIX

  • Problem loading mix/consumer data in the GUI version (#48)

MixSIAR 3.0.1 (2015-10-29)

BUG FIX

  • Fixed an error that applies with source data = means and the "Resid*Process" error structure (affects Wolves, Killer whale, and Isopod examples)

MixSIAR 3.0.0 (2015-10-29)

NEW FEATURES

  • error structures now multivariate, with 3 options: "Residual only", "Residual * Process", "Process only (N=1)"
  • fixed coding of fixed effects (cases with 2FE, 1FE + 1RE)
  • new function plot_prior to plot uninformative vs. informative priors (included in GUI)
  • new function calc_area to calculate Brett (2014) normalized surface area
  • normalized continuous covariate
  • MCMC chains given different initial values (#35)
  • added new examples with fatty acids
  • new manual

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("MixSIAR")

3.1.10 by Brian Stock, a year ago


https://github.com/brianstock/MixSIAR


Report a bug at https://github.com/brianstock/MixSIAR/issues


Browse source code at https://github.com/cran/MixSIAR


Authors: Brian Stock [cre, aut] , Brice Semmens [aut] , Eric Ward [ctb] , Andrew Parnell [ctb] , Andrew Jackson [ctb] , Donald Phillips [ctb]


Documentation:   PDF Manual  


GPL-3 license


Imports ggplot2, rjags, R2jags, MASS, RColorBrewer, reshape, reshape2, lattice, MCMCpack, ggmcmc, coda, loo, bayesplot

Suggests gWidgets, gWidgetsRGtk2, splancs, knitr, rmarkdown, testthat

System requirements: JAGS (>= 4.1) for the script version, both JAGS and GTK+ for the GUI version. For install instructions, see README file.


See at CRAN