16.5 Worked example with the Cray data

In this section, we will apply Bayesian inference to the Cray data, which are first introduced in Chapter 14 Linear Mixed Models. Hopefully, this example also demonstrates that linear models are just one special type of GLM that assume a normal error distribution.

We start by reading in data.

# Read in the data
cray <- read.csv("data/cray.csv")

These data come from a preliminary study of rusty crayfish Faxonius rusticus density in various tributaries to the Susquehanna River. The data were collected as part of a summer research project by one of our former high-school interns at the SUNY Oneonta Biological Field Station .

There are 964 observations of 7 variables. Each of the observations (rows) corresponds to a rusty crayfish that was collected and measured (length in mm and mass in g) at one of several sites on a given date. The variable catch is the total number caught by electrobugging over a given time (minutes). To compare density between sites, catch was divided by (time/60) to calculate catch per unit effort (cpue) as number of crayfish per hour. Therefore, observations of cpue, catch, and time correspond to unique date and site combinations, but length and mass represent unique individuals within site and date.

For now, we will use this data set to estimate the relationship between logelength and logemass of the crayfish as a linear regression, this time as a GLM using Bayesian inference.