Overview

We’re going to use the Northern Bobwhite (hereafter ‘quail’) “whistle count” surveys alongside remotely-sensed tree cover data for our first generalized additive models (GAMs). Broadly, we’ll be comparing quail abundance (measured by whistle counts) to tree cover while accounting for spatiotemporal autocorrelation. Then we’re going to practice writing results for the model outputs.

Download this R script. We’ll use it to work through the challenges today.


Bobwhite Quail by Larus
Bobwhite Quail by Larus

Data description

Column Name Description
Year years 1965 - 2020
County Nebraska county name
Route.Name Route name
Route.Number Route number
UTMXN UTM northing zone 14
UTMYE UTM easting zone 14
WhistleCount Mean whistle count per route per year
Bob_Region Quail management region code

Let’s load the data and tidy it:

#===============================================================================
## Preparations

# # Clear environment?
# rm(list=ls())

# List of packages necessary to run this script:
require(librarian)
shelf(tidyverse, here, sf, brms, maps, terra, tidybayes,
      lib = tempdir())

# Set path
repo_url <- "https://raw.githubusercontent.com/LivingLandscapes/Course_EcologicalModeling/master/data/"

# Set seed
set.seed(2252)

# Load data
dat_list <- 
  list(RouteDictionary = read_csv(paste0(repo_url, "QuailWhistle_Nebraska_RouteDictionary.csv")),
       RouteUTMs = read_csv(paste0(repo_url, "QuailWhistle_Nebraska_RouteUTMs.csv")),
       RouteWhistleData = read_csv(paste0(repo_url, "QuailWhistle_Nebraska_RouteWhistleData.csv")))

#=============================================================================
## Tidying data

# Tidy whistle data
whistle <- 
  dat_list$RouteWhistleData %>%
  pivot_longer(cols = Cass:Lancaster_YH,
               names_to = "Route.Name",
               values_to = "WhistleCount") %>%
  mutate(Route.Name = case_when(Route.Name == "Cass" ~ "Cass North",
                                Route.Name == "GageN" ~ "Gage North",
                                Route.Name == "GageS" ~ "Gage South",
                                Route.Name == "Jeffersn" ~ "Jefferson",
                                Route.Name == "JohnsonN" ~ "Johnson North",
                                Route.Name == "JohnsonS" ~ "Johnson South",
                                Route.Name == "Lancaster.East" ~ "Lancaster East",
                                Route.Name == "Lancaster.North" ~ "Lancaster North",
                                Route.Name == "Lancaster.Branched.Oak" ~ "Lancaster-Branched Oak",
                                Route.Name == "OtoeN" ~ "Otoe North",
                                Route.Name == "OtoeS" ~ "Otoe South",
                                Route.Name == "Richardn" ~ "Richardson",
                                .default = Route.Name)) %>%
  left_join(dat_list$RouteDictionary %>% mutate(Route.Name = `Route Name`)) %>%
  mutate(Route.Number = `Route Number`) %>%
  filter(Route.Name != "Lancaster_YH") %>%
  left_join(dat_list$RouteUTMs %>%
              mutate(Route.Number = Route) %>%
              group_by(Route.Number) %>%
              filter(row_number() == 1)) %>%
  mutate(YearNum = Year - 1964,
         YearNum2 = (Year - 1964)^2,
         Easting_scaled = scale(UTMYE),
         Northing_scaled = scale(UTMXN))