Projects

Animate VEMCO VR2 data in Excel
This program (VBA implemented in Excel) animates the path of a tagged animal in a VR2 hydrohpone network. 
Bayesian MAR(1) model
by brice.semmens, last updated 7/8/08, sharing set to Public
This set of Matlab scripts conducts a first order MAR(1) model to estimate interactive effects, and covariate effects, on a time series of data from a community.It uses a Gibbs sampler to estimate parameters, and currently is set up with diffuse priors on all parameters for the model. It is pretty basic at this point, but it works.
Note on the Gamma distribution:
Going back and forth between Matlab/R/WinBUGS can be confusing, because of the different parameterizations of the gamma pdf. Here's the Matlab/BUGS forms and the R equivalents:
Matlab: X ~ g(a,b) E[X] = ab
R equivalent: X ~ g(shape=a,scale=b)
BUGS: X ~ g(a,b) E[X] = a/b
R equivalent: X ~ g(shape=a,rate=b) OR
X ~ g(shape=a,scale=1/b)

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.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.

Data Cloning I: univariate
by eric.ward, last updated 5/26/08, sharing set to Public
This script writes and runs the data cloning procedure described by Lele et al. (2007, Ecology Letters). The routine is in R, and requires the user to install OpenBUGS before running. The number of clones can (and should) be modified. For this simple example, 100 clones takes ~ 2 minutes on my 2.5 year old laptop (1.66Ghz, 1GB RAM). More details and diagnostics can be found in the multivariate cloning project. 
Gibbs sampler for multiple linear regression
THE FOLLOWING FUNCTION CONDUCTS MULTIPLE LINEAR REGRESSION PARAMETER ESTIMATION VIA MCMC USING GIBBS SAMPLING.
The point of this code is to show how to do it with a conjugate distribution such that the method can easily be plugged into LAMBDA.
The function assumes that:
1)the B coefficients are normally distributed ~N(prior_mean,prior_s2)and thus have a normal distribution prior. Large prior variances produce suitably "diffuse" priors
2) the model variance is gamma distributed Ga(alpha, beta), with an associated prior. Small values of alpha and beta (<.001) produce a suitably "diffuse" prior. Note that Matlab's parameterization of their gamma function is a bit wonky compared to the standard. Basically, Matlab uses Ga(alpha,1/beta) ie. inverse of the standard scale parameter.
The R code contains 2 versions of Bayesian linear regression. The first (univariate.all) uses the multivariate normal distribution to sample regression coefficients; the second (univariate.vat) does variable at a time sampling. Both R versions are nearly identical, allow a flexible range of priors for B, and allow the prior variance to be specified either as the shapescale (e.g. gamma, scaled inv chi sq) or in terms of the meanvariance. Output includes saved parameter draws, which can be fed into CODA, and the calculation of the log(Bayes Factor) to be used for model selection. 
Hierarchical linear model of MPA effects
by brice.semmens, last updated 2/5/08, sharing set to Public
These are a series of Matlab routines to carry out a hierarchical linear model of fish population trajectories that includes a linear adjustment for a "reserve effect" at sites designated as MPAs. %The model is set up as follows: %FIRST LEVEL %MODEL:***** y~ intercept + abundance_index * (S_g + R_t +R_nt) + error *** %where: %S_g is the slope for a given species in a given geographic region (drawn %from a normally distributed species specific hyperparameter) %R_t is a species specific additive adjustment to the slope that is drawn %from a normally distributed hyper parameter representing the reserve effect on harvested species. Activated by a dummy variable. %R_nt is the species specific additive adjustment to the slope that is drawn from a normally distributed hyper parameter %representing the reserve effect on nonharvested species. Activated by a dummy variable. %both intercept and error terms are nuisance parameters and do not need hyperparameters. I suppose you could put in an %error hyper parameter with an informative prior just to keep the model in check. %SECOND LEVEL (hyper parameters all normally distributed) %S_g_hat  These are slopes for a given species from which S_g's are drawn %R_t_hat  This is the reserve effect for targeted species from which R_t's across targeted species are drawn %R_nt_hat  This is the reserve effect for nontarged species from which %R_nt's across nontargeted species are drawn % 
MixBUGS
This code is written to match the MCMC package SIAR in R. Two versions are included, 1 with no residual error, and 1 that models the variation as a mixture of residual + source variance. 
MixBUGS
This code is written to match the MCMC package SIAR in R. Two versions are included, 1 with no residual error, and 1 that models the variation as a mixture of residual + source variance. 
Null model methods
by brice.semmens, last updated 1/7/08, sharing set to Public
These files give code for ecological null model analyses.