# Posts

## How we teach ggplot (in the Insights book)

In our book Insights we help readers learn how to use the amazing ggplot2 package to make visualisations. If you have some experience with ggplot2, you may think our method of teaching it, and of using it in the book are a bit odd. Here we explain our reason for teaching it the way we teach it. For example, here is the code for the first graph we make: bats_Age_Sex %>% ggplot() + geom_col(mapping = aes(x=Sex, y=num_bat_IDs, fill=Age)) And if we had not piped the dataset into ggplot then we would have done this:

## Diagnostic plots of linear models with categotical explanatory variables

[This is a minimal post due to very limited time.] We need to check the assumptions of our linear model (e.g. regression, ANOVA, ANCOVA) are not too badly violated. We often use four diagnostic graphs to do so. One of these shows standardised residuals plotted against leverage (each observation has a value). The take home message of this post is if your model contains at least one continuous explanatory variable, use the base R methods for making your diagnostic plots:

## Lurking variables and hidden relationships

Inspiration for the following from from Richard McElreath’s Statistical Rethinking book, and some of the code comes from here: https://bookdown.org/ajkurz/Statistical_Rethinking_recoded/multivariate-linear-models.html#masked-relationship Let us think about the question of how the response variable y is related to two explanatory variables x1 and x2. First we make a dataset in which we know the relationships because we specify them: we make y = x1 - x2. Before this, we create x1 and x2 and make them correlated…

## Maximum likelihood part 1

This is the first in a series of posts about maximum likelihood methods for fitting statistical models to data. Inspiration for the material comes in large part from Drew Purves who presented something similar. Owen is using Drew’s approach as the basis for this course. Much of the R specific stuff is heavily influenced by Ben Bolker’s excellent book: Ecological Models and Data in R. The goal of this and the following posts includes: learning how to fit to our data more mechanistic models of arbitrary complexity.