Projects for Statespace: 
14 of
4
shown (3 visible only to EcologyBox members).



DARTER (Diffusion Approximation Tools for Extinction Risk Estimation)
by brice.semmens, last updated 8/23/07, sharing set to public
This program allows one to walk through the steps required to conduct a population viability analysis, or PVA, using a population time time series. The model outputs probabilities of extinction as a function of time steps into the future, and importantly, gives confidence intervals for these probabilities.
This tool has two major advantages over traditional PVA techniques:
1) It uses a statespace Kalman filter that allows for both process and nonprocess error.
So what's the big deal? Functionally it filters the data, and allows a more accurate fit for population parameters of interest.
2) It uses a Bayesian samplingimportanceresampling algorithm to fully address uncertainty in the parameter estimates given the data.
So what's the big deal?  Rather than developing a single function that describes the probability of population extinction through time, we can use the uncertainty in parameter estimates to develop 'probabilities of probabilities', or, the uncertainty surrounding the probability of extinction through time.

Generate stochastic population processes
These are function for generating various standard types of stochastic population processes: random walks, OrnsteinUhlenbeck, discrete Gompertz, etc. Also some random number generators needed by these are here. These matlab files need the Matlat Statistics Toolbox. 
KalmanEM
by e2holmes, last updated 10/21/09, sharing set to public
KalmanEM has been replaced by our MARSS R package. Please go to the MARSS project page (where you'll find the manual). You can download MARSS from CRAN or directly from the R GUI using "Install packages". MARSS will appear on the list of available packages.
KalmanEM.R fits mulitvariate state space models to multivariate time series data.
x(t) = B x(t1) + u + e(t), E~MVN(0,Q)
y(t) = Z x(t) + a + eta(t), eta~MVN(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 statespace models available with case studies and examples for estimating trends, evaluating population structure, estimating interactions, and analyzing movement data: MSSM workshop The EM algorithm is similar to that in Shumway and Stoffer (1982) but actually was actually motivated by Ghahramani and Hinton (1996). EM is a hillclimbing algorithm and many times the likelihood surface is multimodel. Use KalmanEM(...,MonteCarloInit = TRUE) to turn on searching of the initial condition space. This will deal with the vanilla multimodel problems.
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 (June 2010): MARSS 1.0, our R package has been relaased. You can download from CRAN MARSS or install directly from your R GUI using "Install packages". MARSS will appear on the list of available packages from R. The package is fully documented with help files, a user manual with welldeveloped examples, and a paper on the derivation behind the EM algorithm. MARSS 1.0 limits a bit what MARSS models you can fit, but these restrictions will be lifted with MARSS 2.0 which we are coding right now. MARSS 2.0 uses a more general EM algorithm to allow you to fit any models of the MARSS form above with fixed and shared values arbitrarily distributed throughout the matrices. 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.

MARSS
by e2holmes, last updated 8/3/10, sharing set to public
Please download the current release of MARSS from CRAN. The current User Guide can be found there also.
A MARSS model is a multivariate autoregressive timeseries model of the form:
x(t) = B x(t1) + u + v(t), v(t)~MVN(0,Q)
y(t) = Z x(t) + a + w(t), w(t)~MVN(0,R)
where all elements of these equations are matrices as this is a multivariate autoregressive model.
What you need to use this code: MARSS is an R package, thus you need to install R from CRAN in order to use the package Once you have R installed, then install the MARSS package using the standard R package instructions (if you are using an R GUI, then you use the "Install Packages" menu.) If you have never done this, see the instructions on CRAN.
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 have a number of online workshops on multivariate statespace models available with case studies and examples for estimating trends, evaluating population structure, estimating interactions, and analyzing movement data: WORKSHOPS Our EM algorithm is similar to that in Shumway and Stoffer (1982) but actually was inspired by Ghahramani and Hinton (1996). Most other software uses the BFGS algorithm (a quasiNewton method) for maximization, which often works great but for some models needs a bit of fiddling to get it to work (not throw numerical errors). Some researchers will use the EM algorithm to "get close" and then polish off with the BFGS algorithm. MARSS includes functions for bootstrapping (parametric and innovations), model selection (AIC, AICc, and bootstrap biascorrected AICb), confidence intervals (approximate via Hessian, parametric bootstrap, and innovations bootstrap), parameter bias estimation (via bootstrapping), simulation, and initial condition searching. MARSS was developed by Eli Holmes, Eric Ward, and Kellie Wills.
See what is coming in the next MARSS version: This is our development site MARSS development site
Learning how to use the code: The user manual gives detailed examples. Scripts and data for all the case studies are included in the package. Our online workshops at EE Holmes' website include pdfs of our lectures.
See our personal websites for group news on papers coming out of this work: EE Holmes website, Eric Ward website, Brice Semmens website, and Mark Scheuerell website. (download stats from CRAN)
Projects for Statespace: 
14 of
4
shown (3 visible only to EcologyBox members).

