Projects found

Projects for mcmc:

1-3 of 3 shown.    
    
1  

  • 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

    by brice.semmens, last updated 7/5/08, sharing set to public
    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 shape-scale (e.g. gamma, scaled inv chi sq) or in terms of the mean-variance. 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 non-harvested 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 non-targed species from which %R_nt's across non-targeted species are drawn %--------------------------------------------------------------------------------------------------------------------------

Projects for mcmc:

1-3 of 3 shown.    
    
1  

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