# Category Archives: Tutorial

## Bayesian ANOVA: Powerful inference with within-group sample size of 1

1 Objective 2 The data 3 Fixed-effects ANOVA in JAGS 4 Relaxing the assumption of constant variance 5 Conclusion This post is inspired by a question by Dylan Craven that he raised during my Bayesian stats course. 1 Objective My aim here is to demonstrate that, in Bayesian setting, one can make powerful inference about… Read More »

## Typesetting beautiful conference posters with Tickzposter

To make a conference poster you probably use some vector editor: Inkscape, Adobe Illustrator, CorelDraw, or maybe LibreOffice Draw, Impress or MS PowerPoint. But you can also code it, and by that I mean using some markup language to actually write how the poster should look like, and then compile the code. Sounds insane at… Read More »

## Survival analysis: basic terms, the exponential model, censoring, examples in R and JAGS

I have put together some basic material on survival analysis. It is available as: .html document with highlighted syntax here. Printer-ready .pdf document here. GitHub repository with all the source files here. Main motivation was that I wanted to learn the basics myself; also, it's tricky to find simple examples of survival models fitted in… Read More »

## Simple template for scientific manuscripts in R markdown

I've made a really simple template for the classical manuscript format for R markdown and knitr. Here are the resulting .pdf and .html. The template contains the four usual components of any scientific manuscript: equations (using LaTeX syntax) table with caption (done by kable package, but you can also use xtable) figure with caption citations… Read More »

## GAM splines now easy in JAGS and OpenBUGS. An example on 2D spatial data

Last week I met Simon Wood, creator of mgcv package, which is THE tool for fitting Generalized Additive Models (GAM) in R. Simon brought my attention to function jagam which he has just added to mgcv. The function allows to transform the ‘spline’ or ‘smooth’ component of GAM model formula into BUGS code, meaning that… Read More »

## Tailoring univariate probability distributions

This post shows how to build a custom univariate distribution in R from scratch, so that you end up with the essential functions: a probability density function, cumulative distribution function, quantile function and random number generator. In the beginning all you need is an equation of the probability density function, from which everyting else can… Read More »

## Poisson regression fitted by glm(), maximum likelihood, and MCMC

The goal of this post is to demonstrate how a simple statistical model (Poisson log-linear regression) can be fitted using three different approaches. I want to demonstrate that both frequentists and Bayesians use the same models, and that it is the fitting procedure and the inference that differs. This is also for those who understand… Read More »

## Spatial correlograms in R: a mini overview

Spatial correlograms are great to examine patterns of spatial autocorrelation in your data or model residuals. They show how correlated are pairs of spatial observations when you increase the distance (lag) between them - they are plots of some index of autocorrelation (Moran's I or Geary's c) against distance. Although correlograms are not as fundamental… Read More »

## Gridding data for multi-scale macroecological analyses

These are materials for the first practical lesson of the Spatial Scale in Ecology course. All of the data and codes are available here. The class covered a 1.5h session. R code for the session is also at the end of this post. The following advices and ideas are mostly my personal opinions, they were… Read More »