# Articles by petrkeil

### Spatial autocorrelation of errors in JAGS

February 10, 2014 |

In the core of kriging, Generalized-Least Squares (GLS) and geostatistics lies the multivariate normal (MVN) distribution – a generalization of normal distribution to two or more dimensions, with the option of having non-independent variances (i.e. autocorrelation). In this post I will show: (i) how to use exponential decay and the … ... [Read more...]

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

October 29, 2013 |

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 … ... [Read more...]

### The joy and martyrdom of trying to be a Bayesian

August 30, 2013 |

Some of my fellow scientists have it easy. They use predefined methods like linear regression and ANOVA to test simple hypotheses; they live in the innocent world of bivariate plots and lm(). Sometimes they notice that the data have odd histograms and they use glm(). The more educated ones use … ... [Read more...]

### Spatial correlograms in R: a mini overview

May 21, 2013 |

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…Read more → [Read more...]

### Beware: 2 is not always 2 in R

May 14, 2013 |

This post is minimalistic. Consider this: Now let's have look at what's inside x: But is it really true? Here you go. A colleague of mine was once ruined by this for an entire day before we realized what was…Read more → [Read more...]

### AIC & BIC vs. Crossvalidation

May 4, 2013 |

Model selection is a process of seeking the model in a set of candidate models that gives the best balance between model fit and complexity (Burnham & Anderson 2002). I have always used AIC for that. But you can also…Read more → [Read more...]

### Gridding data for multi-scale macroecological analyses

April 22, 2013 |

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…Read more → [Read more...]

### Not all proportion data are binomial outcomes

March 24, 2013 |

It really is trivial. Not every proportion is frequency. There are things that have values  bounded between 0 and 1 and yet they are neither probabilities, nor frequencies. Why do I even bother to write this? Because some kinds of…Read more → [Read more...]

### Predictors, responses and residuals: What really needs to be normally distributed?

February 18, 2013 |

Introduction Many scientists are concerned about normality or non-normality of variables in statistical analyses. The following and similar sentiments are often expressed, published or taught: "If you want to do statistics, then everything needs to be normally distributed." "We normalized…Read more → [Read more...]

### Data-driven science is a failure of imagination

January 2, 2013 |

Professor Hans Rosling certainly is a remarkable figure. I recommend watching his performances. Especially the BBC's "Joy of Stats" is exemplary. Rosling sells passion for data, visual clarity and great deal of comedy. He represents the data-driven paradigm in science. What…Read more → [Read more...]

### Fast Conway’s game of life in R

November 25, 2012 |

Here I demonstrate a simple way to code Conway's game of life (GoL) in R and to produce the animation above. Cellular automata in R are usually painfully slow if you iterate through all grid cells in an array. A…Read more → [Read more...]

### The simplest Species Distribution Model in OpenBUGS & R

September 27, 2012 |

This post demonstrates the simplest Species Distribution Model based on logistic regression for presence/absence data. I heavily simplified the example from Kéry (2010): Introduction to WinBUGS for Ecologists, Chapter 20.Read more → [Read more...]

### Using R for parallelizing OpenBUGS on a single Windows PC

August 22, 2012 |

It seems that most of the R-parallelizing business takes place on Linux clusters. And it makes sense. Why would you want to paralellize R on just a few processors (2 or 4) of a Windows laptop PC when the whole…Read more → [Read more...]

### Linear regression in OpenBUGS

August 18, 2012 |

I always wondered why is it so difficult to find an OpenBUGS example of simple linear regression on the Web. Curiously, such example is even missing in the OpenBUGS help. The only nice example so far is in the book … Continue reading → [Read more...]