by eric.ward, last updated 6/5/07, sharing set to PublicThese routines allow you to take a matrix of MCMC samples and calculate the Bayes factor based on the harmonic mean algorithm proposed by Gelfand and Dey (1994). Caution: Bayes factors tend to be numerically unstable!
by eric.ward, last updated 11/20/09, sharing set to Public
This project is a variation of stable isotope mixing models. Previous approaches have fixed source parameters (mean, variance) at their MLE estimates, and proceeded to do a Bayesian analysis of the mixture of consumer diets. This assumption is fine when sample sizes are large, but often in ecology, they are small. Incorporating this uncertainty adds additional parameters, and slightly increases the total variance of mixture estimates, but has the advantage of improving mixing and reducing bias. Often, using the traditional approach may lead to multi-modal estimates of the mixture; we demonstrate that the fully Bayesian mixing model avoids this problem. A final benefit is that it allows prior information about sources to be included. The code folder contains the code to replicate the comparison done with simulated datasets.
by eric.ward, last updated 2/22/09, sharing set to Public
Before you begin with this code, make sure you download the latest release of OpenBUGS(now 3.0.3) and it is installed to the default directory, "C:\Program Files\OpenBUGS". We've also found that it helps to have a cleaned up registry + defregmented hard drive before using OpenBUGS. The version of R that you're using should also be noted - R 2.5.1 and 2.7.0 work great with OpenBUGS, but there was a glitch in R 2.6.0 that prevented OpenBUGS from ever running through R. When using BUGS, I think that you can obviously use WinBUGS or OpenBUGS. While both programs should yield the same result, I had much more success with OpenBUGS, particularly in terms of the program not crashing during the burn-in (anyone familiar with 'trap' error messages knows what I'm talking about). There are 2 project files. The first (writeModel.r) is sourced by the second file (runDataCloning2.r). If you want to modify the bounds on parameters, you'll need to edit writeModel.r - otherwise, everything will be done behind the scenes. I've tried to predict many of the errors that might occur - for example, it doesn't make sense to have all sites belonging to the same group (m = 1) and an unconstrained covariance matrix. These files won't automate every possible MSSM that you want to fit, but they will do the majority of them. The R script files actually write the BUGS code for you, so you don't have to know any BUGS coding. You should however, be aware of the priors. Uniform priors are used on SDs and growth rates - to change these, look anywhere in the file for (~ dunif(a,b), where a and b are the limits). The code also includes the option of including an interaction matrix (multiple species) or density dependence matrix (multiple populations). The priors for all of these terms are bounded (0,1). Included are several examples of summarizing parameters, including the median, mean, and using density to estimate the mode. The actual MLEs are going to be the points associated with the best (lowest) density.
by eric.ward, last updated 5/19/10, sharing set to Public
This project is related to the stable isotope mixing models that include heterogeneity in individual diets and hierarchical nested structures (individuals in groups, groups in regions, etc). All code provided is to be used with R and either JAGS or BUGS (everything was validated using JAGS on a Mac)
by brice.semmens, last updated 8/8/10, sharing set to PublicExample files from the IsoEcol7 mixing model workshop.
by eric.ward, last updated 9/24/08, sharing set to Public
This project includes the WinBUGS files illustrating how to include model selection in MCMC. Variances are modeled as a mixture of source/fractionation and additional residual variance. We include to variations on the MixBUGS model, 1 without residual variance, and 1 modeling variance as a mixture (to calculate posterior probabilities). We also include the R-script illustrating that the SIAR package likely contains a bug (even when data are generated from a 0.7-0.2-0.1 mixture, estimated contributions are nearly equal).
by eric.ward, last updated 2/10/11, sharing set to PublicThis code integrates over different source groupings, as described in the Ward et al. (2010) Ecosphere paper
by brice.semmens, last updated 10/2/13, sharing set to Public*Update 8/6/14*
MixSIAR is now being hosted on GitHub at https://github.com/brianstock/MixSIAR/releases. Below the release notes, click the "Source code (zip)" button to download the .zip folder with the code and user manual.
NOTE: I have not yet updated the User Manual, but I thought they were important enough to release now. Stay tuned for the updated manual!
Important changes from the MixSIAR v1.0 code:
- Several bug/error fixes
- New scripted version, check out "mixsiar_script.r"
- Altered the GUI function call to:
- Added option for fixed effects
- Separated OUTPUT button from RUN MODEL button
- Simplified MCMC options (now choose from "test", "short", "long", etc. See "mixsiar_script.r" for details)
by brice.semmens, last updated 8/17/12, sharing set to Public
MixSIR is a Bayesian isotope mixing model that incorporates uncertainty in the estimates of mix and source isotope values. The model also provides the opportunity to incorporate prior information for the proportional contribution of each source to the mix. The programs for this project are written in Matlab. I have provided the source files as well as an .exe file package so that those without Matlab can run the program. Collaborations and improvements are welcome! Prior to installing MixSIR you MUST download the (free) Matlab component runtime library and run it once on your machine. Note also that installing new versions of MixSIR will require a new download and installation of the component runtime library.
***** NOT WORKING ON YOUR NEW 64 BIT MACHINE?? *****
-- You need to install this:
you're runnning a 32-bit compiled Matlab app on a 64-bit Windows machine, and it's not finding the 32-bit Visual C++ runtime it's linked against. The Microsoft software "Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)" will fix the problem. Cut and paste the link above to get the software fix!
by eric.ward, last updated 1/10/11, sharing set to PublicThere are two bits of code here - unfortunately, we only have both for implementation on a PC. 1. A R/C program to run the SIR algorithm and create posterior distributions from the negative binomial distribution given a sample of offspring, a census of parents, and associated summary statistics for offspring per parent (sample mean, sample variance). This algorithm is also available entirely in R, but we haven't posted it because it's extremely slow. If you're interested, it's available from the authors upon request. 2. A visual basic program to evaluate Type I error rates for assignment. A user will have to download and install the PopTools add-in for MS Excel/Visual Basic (http://www.poptools.org/).
These files are a collection of Java functions I've written to calculate PDFs/log likelihoods, and to do a variety of random number generator. You can use the built in Java random number generator, but I chose to link these files to the free RngPack library.
by brice.semmens, last updated 6/28/11, sharing set to PublicThese are the files for Eric and Brice's mixing model lab @ Trinity.