Preparations

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

Scenario

Starlings

Starlings

Format of starling_full.RSV data files

SITUATION MONTH MASS BIRD
tree Nov 78 tree1
.. .. .. ..
nest-box Nov 78 nest-box1
.. .. .. ..
inside Nov 79 inside1
.. .. .. ..
other Nov 77 other1
.. .. .. ..
tree Jan 85 tree1
.. .. .. ..
SITUATION Categorical listing of roosting situations (tree, nest-box, inside or other)
MONTH Categorical listing of the month of sampling.
MASS Mass (g) of starlings.
BIRD Categorical listing of individual bird repeatedly sampled.

Read in the data

starling = read_csv('data/starling_full.csv', trim_ws=TRUE)
## Parsed with column specification:
## cols(
##   MONTH = col_character(),
##   SITUATION = col_character(),
##   subjectnum = col_integer(),
##   BIRD = col_character(),
##   MASS = col_integer()
## )
glimpse(starling)
## Observations: 80
## Variables: 5
## $ MONTH      <chr> "Nov", "Nov", "Nov", "Nov", "Nov", "Nov", "Nov", "N...
## $ SITUATION  <chr> "tree", "tree", "tree", "tree", "tree", "tree", "tr...
## $ subjectnum <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7,...
## $ BIRD       <chr> "tree1", "tree2", "tree3", "tree4", "tree5", "tree6...
## $ MASS       <int> 78, 88, 87, 88, 83, 82, 81, 80, 80, 89, 78, 78, 85,...

Exploratory data analysis

Model formula: \[ y_i \sim{} \mathcal{N}(\mu_i, \sigma^2)\\ \mu_i =\boldsymbol{\beta} \bf{X_i} + \boldsymbol{\gamma} \bf{Z_i} \]

where \(\boldsymbol{\beta}\) and \(\boldsymbol{\gamma}\) are vectors of the fixed and random effects parameters respectively and \(\bf{X}\) is the model matrix representing the overall intercept and effects of roosting situation and month on starling mass. \(\bf{Z}\) represents a cell means model matrix for the random intercepts associated with individual birds.

Fit the model

Model validation

Model investigation / hypothesis testing

Predictions

Summary figures

References