Load the necessary libraries
library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
Here is a modified example from Peake and Quinn (1993). Peake and Quinn (1993) investigated the relationship between the number of individuals of invertebrates living in amongst clumps of mussels on a rocky intertidal shore and the area of those mussel clumps.
Format of peakquinn.csv data files
AREA | INDIV |
---|---|
516.00 | 18 |
469.06 | 60 |
462.25 | 57 |
938.60 | 100 |
1357.15 | 48 |
... | ... |
AREA | Area of mussel clump mm2 - Predictor variable |
INDIV | Number of individuals found within clump - Response variable |
The aim of the analysis is to investigate the relationship between mussel clump area and the number of non-mussel invertebrate individuals supported in the mussel clump.
peake = read_csv('data/peakquinn.csv', trim_ws=TRUE)
## Parsed with column specification:
## cols(
## AREA = col_double(),
## INDIV = col_integer()
## )
glimpse(peake)
## Observations: 25
## Variables: 2
## $ AREA <dbl> 516.00, 469.06, 462.25, 938.60, 1357.15, 1773.66, 1686.0...
## $ INDIV <int> 18, 60, 57, 100, 48, 118, 148, 214, 225, 283, 380, 278, ...
Model formula: \[ y_i \sim{} \mathcal{Pois}(\lambda_i)\\ ln(\lambda_i) = \beta_0 + \beta_1 ln(x_i) \]
Peake, A. J., and G. P. Quinn. 1993. “Temporal Variation in Species-Area Curves for Invertebrates in Clumps of an Intertidal Mussel.” Ecography 16: 269–77.