As a statistical pragmatist, I am comfortable applying a variety of tools depending on the data and questions. Because my data and questions tend to be complex, they often violate the assumptions of conventional approaches, so I increasingly develop multilevel Bayesian statistical models. While flexible and powerful, multilevel Bayesian models are not widely applied because articulating and fitting models requires both skill and artistry. Developing these skills succeeds best in a supportive community with lots of examples. To support the community, I regularly contribute to the annual workshop at the Ecological Society of America Meetings. To provide more examples of code, I am posting annotated versions from various projects here.
The attached code fits a simple heirarchical regression model. Nothing complicated, but a useful exercise for beginners.
Many of the datasets that I analyze are explictly spatial. Space can influence analyses in many ways. As the famous saying goes, "everything is related to everything else, but near things are more related than distant things." (Tobler W., (1970) "A computer movie simulating urban growth in the Detroit region". Economic Geography, 46(2): 234-240). To account for spatial dependence, I often fit Gaussian Conditional Autoregressive effects. Doing so requires classifying observations into spatial neighborhoods. The attached code includes some R script for doing that, along with BUGS code for fitting a model with a Gaussian CAR prior structure over the intercept. You can think of it as a basic spatial random effect. Click on the image for a link to the .txt file.
The attached code is provided as a supplement to Oberle et al. 2016. It fits several Weibull vessel length models to dye injection data. It also includes the likelihood for the overdispersed counts model formulation of the negative binomial distribution.
Please click the photo of the data from Quercus rubra for a link to the code file.
Please send me an email with your feedback about the design.