Projects found

Results for keyword R :

1-3 of 3 shown.

  • Bayesian SI mixing models

    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.
  • Kalman-EM

    KalmanEM.R fits mulitvariate state space models to multivariate time series data.

    X(t) = B X(t-1) + U + E(t), E~N(0,Q)

    Y(t) = Z X(t) + A + eta(t), eta~N(0,R)

    What you need to use this code: Download KalmanEM.R (or scroll down to download all the files).  Open R and source("KalmanEM.R").  That's it.  For basic analyses, all the packages you need are included in the base R distribution.

    About this code: This code is used to estimate maximum likelihood parameters for multivariate state space time series models via an EM algorithm using the Kalman filter+smoother. We assume that there are N observation time series over T years, and that there may be shared parameters (growth rates, process error, observation error) across sites. Further, the errors may be correlated between sites and the N sites may be clustered into groups. We have a number of online workshops on multivariate state-space models available with case studies and examples for estimating trends, evaluating population structure, estimating interactions, and analyzing movement data: MSSM workshop  The base EM algorithm is from Shumway and Stoffer (2006). EM is a hill-climbing algorithm and many times the likelihood surface is multi-model. Use KalmanEM(...,MonteCarloInit = TRUE) to turn on searching of the initial condition space. This will deal with the vanilla multi-model problems. The "help files.pdf" file has the R help files for the main functions.

    Learning how to use the code: Case Studies.pdf is effectively the current manual. Scripts and data for all the case studies are in the zip file Case studies scripts.zip. The easiest way to learn this code to read case studies 1 and 2 in the Case Studies.pdf. That will walk you through four applications. I have removed Case Study 4 which is on estimation of interactions. Currently we are researching the robustness of estimating interaction terms using MARSS models when the R matrix is free (estimated). One approach is to use a fixed R matrix, but that option is not in the current code. So use caution (meaning test, test, test) if you are using the option B.constraint="unconstrained".

    Project news (Nov 2009):  See the file update_info.txt for changes in the code since 8/6/08 and the original release. We are in active development of MARSS 3.0, which is a complete reorganization of the code to make it into an R package.  MARSS 3.0 uses a general EM algorithm to allow you to fit any models of the MSSM form above with fixed values arbitrarily distributed through the matrices.  On Nov 6th, we completed our beta package and are in the final testing phase.  We are also actively working on Bayesian versions and non-Normal versions.  See our personal websites for group news on papers and code coming out of this work: EE Holmes website, Eric Ward website, Brice Semmens website, and Mark Scheuerell website.

  • MixBUGS

    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).
1-3 of 3 shown.

Sculpin 0.2 | xhtml | problems or comments? | report bugs