Blog Archives

Stochastic search variable selection in JAGS

March 22, 2014
By
Stochastic search variable selection in JAGS

Stochastic search variable selection (SSVS) identifies promising subsets of multiple regression covariates via Gibbs sampling (George and McCulloch 1993). Here’s a short SSVS demo with JAGS and R.Assume we have a multiple regression problem:We suspect only a subset of the elements of $\boldsymbol{\beta}$ are non-zero, i.e. some of the covariates have no effect.Assume $\boldsymbol{\beta}$...

Read more »

Better living through zero-one inflated beta regression

February 6, 2014
By
Better living through zero-one inflated beta regression

Dealing with proportion data on the interval $$ is tricky. I realized this while trying to explain variation in vegetation cover. Unfortunately this is a true proportion, and can’t be made into a binary response. Further, true 0’s and 1’s rule out beta regression. You could arcsine square root transform the data (but shouldn’t; Warton and Hui 2011)....

Read more »

Errors-in-variables models in stan

November 27, 2013
By
Errors-in-variables models in stan

In a previous post, I gave a cursory overview of how prior information about covariate measurement error can reduce bias in linear regression. In the comments, Rasmus Bååth asked about estimation in the absence of strong priors. Here, I’ll describe a Bayesian approach for estimation and correction for covariate measurement error using a latent-variable based errors-in-variables...

Read more »

R and my divorce from Word

October 30, 2013
By
R and my divorce from Word

Being in grad school, I do a lot of scholarly writing that requires associated or embedded R analyses, figures, and tables, plus bibliographies.Microsoft Word makes this unnecessarily difficult.Many tools are now available to break free from the tyranny of Word. The ones I like involve writing an article in markdown format, integrating all data preparation,...

Read more »

How heavy is the Siberut macaque? A Bayesian phylogenetic approach

September 30, 2013
By
How heavy is the Siberut macaque? A Bayesian phylogenetic approach

Among-species comparisons can include phylogenetic information to account for non-independence arising from shared evolutionary history. Often, phylogenetic topologies and branch lengths are not known exactly, but are estimated with uncertainty. This uncertainty can be accounted for using methods recently described in a neat paper called Bayesian models for comparative analysis integrating phylogenetic uncertainty by Villemereuil et...

Read more »

Animating the Metropolis algorithm

September 8, 2013
By
Animating the Metropolis algorithm

The Metropolis algorithm, and its generalization (Metropolis-Hastings algorithm) provide elegant methods for obtaining sequences of random samples from complex probability distributions. When I first read about modern MCMC methods, I had trouble visualizing the convergence of Markov chains in higher dimensional cases. So, I thought I might put together a visualization in a two-dimensional case.I’ll use...

Read more »

Quantifying uncertainty around R-squared for generalized linear mixed models

August 22, 2013
By
Quantifying uncertainty around R-squared for generalized linear mixed models

People love $R^2$. As such, when Nakagawa and Schielzeth published an article in the journal Methods in Ecology and Evolution earlier this year, ecologists (amid increasing use of generalized linear mixed models (GLMMs)) rejoiced. Now there’s an R function that automates $R^2$ calculations for GLMMs fit with the lme4 package.$R^2$ is usually reported as a...

Read more »

Clarifying vague interactions

August 18, 2013
By
Clarifying vague interactions

For some reason, authors occasionally present linear model results with vague or unintelligible interaction effects. One way to be vague when presenting interaction effects is to provide only a table of model coefficients, including no information on the range of covariate values observed, and no plots to aid in interpretation. Here’s an example:Suppose you have discovered a statistically significant...

Read more »

Occupancy model fit & AUC

July 30, 2013
By
Occupancy model fit & AUC

Occupancy models are used to understand species distributions while accounting for imperfect detection. In this post, I’ll demonstrate a method to evaluate the performance of occupancy models based on the area under a receiver operating characteristic curve (AUC), as published last year by Elise Zipkin and colleagues in Ecological Applications.Suppose we are to fit a multi-year occupancy...

Read more »

Split violin plots

June 25, 2013
By
Split violin plots

(This article was first published on Ecology in silico, and kindly contributed to R-bloggers) Violin plots are useful for comparing distributions. When data are grouped by a factor with two levels (e.g. males and females), you can split the violins in half to see the difference between groups. Consider a 2 x 2 factorial experiment: treatments A and B...

Read more »