Assessment v1

Author

Martin Cooper

To help structure my assessment, this lays out the steps I want to follow

Initial Dataset Import and Inspection

#packages needed
library(readr)
library(lubridate)

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(knitr)
library(kableExtra)

Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':

    group_rows

Deployments

#deployments
deployment <- read_csv("deployments.csv",
                       col_types = cols(start_date = col_character())) 

str(deployment)
spc_tbl_ [19 × 29] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ project_id                : num [1:19] 2e+06 2e+06 2e+06 2e+06 2e+06 ...
 $ deployment_id             : chr [1:19] "WM08.2" "WM01.2 Ground" "WM12.1" "WM08.2 Ground" ...
 $ longitude                 : num [1:19] -117 -117 -117 -117 -117 ...
 $ latitude                  : num [1:19] 45.2 45.2 45.1 45.2 45.1 ...
 $ start_date                : chr [1:19] "2020-10-09 00:00:00" "2020-10-08 00:00:00" "2020-10-14 00:00:00" "2020-10-09 00:00:00" ...
 $ end_date                  : POSIXct[1:19], format: "2021-10-20" "2021-10-19" ...
 $ bait_type                 : chr [1:19] "Meat" "Meat" "Meat" "Meat" ...
 $ bait_description          : logi [1:19] NA NA NA NA NA NA ...
 $ feature_type              : chr [1:19] "None" "None" "None" "None" ...
 $ feature_type_methodology  : logi [1:19] NA NA NA NA NA NA ...
 $ camera_id                 : num [1:19] 2030995 2030965 2031138 2030997 2032609 ...
 $ camera_name               : chr [1:19] "WM08 Runpole" "WM01 Ground" "WM12.1" "WM08.2 Ground" ...
 $ quiet_period              : num [1:19] 0 0 0 0 0 0 0 0 0 0 ...
 $ camera_functioning        : chr [1:19] "Camera Functioning" "Camera Functioning" "Camera Functioning" "Camera Functioning" ...
 $ sensor_height             : chr [1:19] "Other" "Chest height" "Other" "Other" ...
 $ height_other              : chr [1:19] "8'-12'" NA "8'-12'" "8'-12'" ...
 $ sensor_orientation        : chr [1:19] "Parallel" "Parallel" "Parallel" "Parallel" ...
 $ orientation_other         : logi [1:19] NA NA NA NA NA NA ...
 $ plot_treatment            : logi [1:19] NA NA NA NA NA NA ...
 $ plot_treatment_description: logi [1:19] NA NA NA NA NA NA ...
 $ detection_distance        : logi [1:19] NA NA NA NA NA NA ...
 $ subproject_name           : logi [1:19] NA NA NA NA NA NA ...
 $ subproject_design         : logi [1:19] NA NA NA NA NA NA ...
 $ event_name                : logi [1:19] NA NA NA NA NA NA ...
 $ event_description         : logi [1:19] NA NA NA NA NA NA ...
 $ event_type                : logi [1:19] NA NA NA NA NA NA ...
 $ recorded_by               : logi [1:19] NA NA NA NA NA NA ...
 $ fuzzed                    : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ deployment_fuzzed         : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 - attr(*, "spec")=
  .. cols(
  ..   project_id = col_double(),
  ..   deployment_id = col_character(),
  ..   longitude = col_double(),
  ..   latitude = col_double(),
  ..   start_date = col_character(),
  ..   end_date = col_datetime(format = ""),
  ..   bait_type = col_character(),
  ..   bait_description = col_logical(),
  ..   feature_type = col_character(),
  ..   feature_type_methodology = col_logical(),
  ..   camera_id = col_double(),
  ..   camera_name = col_character(),
  ..   quiet_period = col_double(),
  ..   camera_functioning = col_character(),
  ..   sensor_height = col_character(),
  ..   height_other = col_character(),
  ..   sensor_orientation = col_character(),
  ..   orientation_other = col_logical(),
  ..   plot_treatment = col_logical(),
  ..   plot_treatment_description = col_logical(),
  ..   detection_distance = col_logical(),
  ..   subproject_name = col_logical(),
  ..   subproject_design = col_logical(),
  ..   event_name = col_logical(),
  ..   event_description = col_logical(),
  ..   event_type = col_logical(),
  ..   recorded_by = col_logical(),
  ..   fuzzed = col_logical(),
  ..   deployment_fuzzed = col_logical()
  .. )
 - attr(*, "problems")=<externalptr> 

This data needs a little reformating for timestamps:

deployment$start_date <- as.POSIXct(deployment$start_date, format="%Y-%m-%d")
# Remove accidental extra spaces in the dataset
deployment$deployment_id <- trimws(deployment$deployment_id)
names(deployment)
 [1] "project_id"                 "deployment_id"             
 [3] "longitude"                  "latitude"                  
 [5] "start_date"                 "end_date"                  
 [7] "bait_type"                  "bait_description"          
 [9] "feature_type"               "feature_type_methodology"  
[11] "camera_id"                  "camera_name"               
[13] "quiet_period"               "camera_functioning"        
[15] "sensor_height"              "height_other"              
[17] "sensor_orientation"         "orientation_other"         
[19] "plot_treatment"             "plot_treatment_description"
[21] "detection_distance"         "subproject_name"           
[23] "subproject_design"          "event_name"                
[25] "event_description"          "event_type"                
[27] "recorded_by"                "fuzzed"                    
[29] "deployment_fuzzed"         

Images

camtraps <- read.csv("images.csv")
str(camtraps)
'data.frame':   81868 obs. of  30 variables:
 $ project_id             : int  2003809 2003809 2003809 2003809 2003809 2003809 2003809 2003809 2003809 2003809 ...
 $ deployment_id          : chr  "WM10.2 Ground" "WM10.2 Ground" "WM10.2 Ground" "WM10.2 Ground" ...
 $ image_id               : chr  "0ebd72b9-ac23-4aa2-a59a-6994090772a3" "cfc1aa92-ec3c-4e23-b098-bfe384bac369" "354a921b-efdc-4ba4-bf64-f839e691af6c" "2c6a8ce1-f5fb-4319-a8be-db5a7bd0956d" ...
 $ sequence_id            : int  1121312 1121312 1121312 1121312 1121312 1121312 1121312 1121312 1121312 1121312 ...
 $ filename               : chr  "IMG_0526.JPG" "IMG_0524.JPG" "IMG_0529.JPG" "IMG_0525.JPG" ...
 $ location               : chr  "https://app.wildlifeinsights.org/download/2018087/project/2003809/data-files/0ebd72b9-ac23-4aa2-a59a-6994090772a3" "https://app.wildlifeinsights.org/download/2018087/project/2003809/data-files/cfc1aa92-ec3c-4e23-b098-bfe384bac369" "https://app.wildlifeinsights.org/download/2018087/project/2003809/data-files/354a921b-efdc-4ba4-bf64-f839e691af6c" "https://app.wildlifeinsights.org/download/2018087/project/2003809/data-files/2c6a8ce1-f5fb-4319-a8be-db5a7bd0956d" ...
 $ is_blank               : logi  NA NA NA NA NA NA ...
 $ identified_by          : chr  "Kayla Dreher" "Kayla Dreher" "Kayla Dreher" "Kayla Dreher" ...
 $ wi_taxon_id            : chr  "febff896-db40-4ac8-bcfe-5bb99a600950" "febff896-db40-4ac8-bcfe-5bb99a600950" "febff896-db40-4ac8-bcfe-5bb99a600950" "febff896-db40-4ac8-bcfe-5bb99a600950" ...
 $ class                  : chr  "Mammalia" "Mammalia" "Mammalia" "Mammalia" ...
 $ order                  : chr  "Cetartiodactyla" "Cetartiodactyla" "Cetartiodactyla" "Cetartiodactyla" ...
 $ family                 : chr  "Cervidae" "Cervidae" "Cervidae" "Cervidae" ...
 $ genus                  : chr  "Odocoileus" "Odocoileus" "Odocoileus" "Odocoileus" ...
 $ species                : chr  "hemionus" "hemionus" "hemionus" "hemionus" ...
 $ common_name            : chr  "Mule Deer" "Mule Deer" "Mule Deer" "Mule Deer" ...
 $ uncertainty            : logi  NA NA NA NA NA NA ...
 $ timestamp              : chr  "2021-06-14 06:13:52" "2021-06-14 06:13:50" "2021-06-14 06:14:08" "2021-06-14 06:13:51" ...
 $ age                    : logi  NA NA NA NA NA NA ...
 $ sex                    : logi  NA NA NA NA NA NA ...
 $ animal_recognizable    : logi  NA NA NA NA NA NA ...
 $ individual_id          : logi  NA NA NA NA NA NA ...
 $ number_of_objects      : int  1 1 1 1 1 1 1 1 1 1 ...
 $ individual_animal_notes: logi  NA NA NA NA NA NA ...
 $ behavior               : logi  NA NA NA NA NA NA ...
 $ highlighted            : chr  "false" "false" "false" "false" ...
 $ markings               : logi  NA NA NA NA NA NA ...
 $ cv_confidence          : logi  NA NA NA NA NA NA ...
 $ license                : chr  "CC-BY" "CC-BY" "CC-BY" "CC-BY" ...
 $ fuzzed                 : chr  "false" "false" "false" "false" ...
 $ deployment_fuzzed      : chr  "false" "false" "false" "false" ...

As with the deployment data, this needs a slight modification

camtraps$timestamp<-as.POSIXct(camtraps$timestamp, format="%Y-%m-%d %H:%M:%S")
names(camtraps)
 [1] "project_id"              "deployment_id"          
 [3] "image_id"                "sequence_id"            
 [5] "filename"                "location"               
 [7] "is_blank"                "identified_by"          
 [9] "wi_taxon_id"             "class"                  
[11] "order"                   "family"                 
[13] "genus"                   "species"                
[15] "common_name"             "uncertainty"            
[17] "timestamp"               "age"                    
[19] "sex"                     "animal_recognizable"    
[21] "individual_id"           "number_of_objects"      
[23] "individual_animal_notes" "behavior"               
[25] "highlighted"             "markings"               
[27] "cv_confidence"           "license"                
[29] "fuzzed"                  "deployment_fuzzed"      

First Checks Camtrap data

How many photos are there:

number <- nrow(camtraps) # number of rows in the dataset
print(paste("Number of photographs:", number))
[1] "Number of photographs: 81868"

Other inital dataset information

# Count how many times the genus has not been identified, and therefor the photograph does not contain relevant species
empty_genus <- sum(camtraps$genus == "")
# Proportion of dataset

proportion <- (empty_genus/nrow(camtraps))*100
print(paste("Photos with no Genus ID:",empty_genus))
[1] "Photos with no Genus ID: 12853"
print(paste("Percentage of photographs without animal captures:",proportion))
[1] "Percentage of photographs without animal captures: 15.6996628719402"

Number of species:

# Combine genus and species into a full species name
camtraps$full_species <- paste(camtraps$genus, camtraps$species, sep = " ")

# Extract unique species
unique_species <- unique(camtraps$full_species)

# Count the number of unique species
print(paste("Number of unique species:",length(unique_species)))
[1] "Number of unique species: 23"
# View the unique species
print(unique_species)
 [1] "Odocoileus hemionus"         "Martes caurina"             
 [3] " "                           "Ursus americanus"           
 [5] "Homo sapiens"                "Cyanocitta stelleri"        
 [7] "Cervus canadensis"           "Gulo gulo"                  
 [9] "Tamiasciurus hudsonicus"     "Vulpes vulpes"              
[11] "Perisoreus canadensis"       "Cervus elaphus"             
[13] "Canis latrans"               "Lepus americanus"           
[15] "Canis familiaris"            "Poecile gambeli"            
[17] "Picoides arcticus"           "Canis lupus"                
[19] "Homo "                       "Callospermophilus lateralis"
[21] "Tamias "                     "Puma concolor"              
[23] "Glaucomys sabrinus"         

This is the total number of photos but we need to filter out those that are incorrectly or incompletely identified

# only Homo species are sapiens, so we can add that data
camtraps <- camtraps %>%
  mutate(species = ifelse(genus == "Homo" & species == "", "sapiens", species))

# a similar argument could be made for the Tamias genus as this only has one extant species under current taxonomy, but this is less certain and is not a species of interest, so no adjustment will be made to this

# Clean trailing/leading spaces
camtraps$deployment_id <- trimws(camtraps$deployment_id)

Remove incomplete identifications

# Check for missing values in genus
  missing_genus <- sum(is.na(camtraps$genus) | camtraps$genus == "")
# Check for missing values in species
  missing_species <- sum(is.na(camtraps$species) | camtraps$species == "")

missing_genus
[1] 12853
missing_species
[1] 12873

There are missing data fields, so lets remove them.

# Filter out rows with missing or empty genus
camtraps <- camtraps %>%
  filter(!is.na(genus) & genus != "")

camtraps <- camtraps %>%
  filter(!is.na(species) & species != "")
  
# Combine 'genus' and 'species' into a new 'full_species' column in the camtraps dataset
camtraps <- camtraps %>%
  mutate(
    full_species = paste(genus, species, sep = " "),  # Combine genus and species
    full_species = trimws(full_species)  # Remove any leading/trailing whitespace
    ) 

Check the dataset again to ensure removal completed as expected.

# Extract unique species
unique_species <- unique(camtraps$full_species)

# Count the number of unique species
print(paste("Number of unique species:",length(unique_species)))
[1] "Number of unique species: 20"
# View the unique species
print(unique_species)
 [1] "Odocoileus hemionus"         "Martes caurina"             
 [3] "Ursus americanus"            "Homo sapiens"               
 [5] "Cyanocitta stelleri"         "Cervus canadensis"          
 [7] "Gulo gulo"                   "Tamiasciurus hudsonicus"    
 [9] "Vulpes vulpes"               "Perisoreus canadensis"      
[11] "Cervus elaphus"              "Canis latrans"              
[13] "Lepus americanus"            "Canis familiaris"           
[15] "Poecile gambeli"             "Picoides arcticus"          
[17] "Canis lupus"                 "Callospermophilus lateralis"
[19] "Puma concolor"               "Glaucomys sabrinus"         

This looks as expected so lets move on.

First Checks Deployments

#count number of deployments
unique_deployments <- unique(deployment$deployment_id)
num_all_deployments <- length(unique_deployments)
#count number of successful deployments
successful_deployments<- unique(camtraps$deployment_id)
num_successful_deployments <-length(successful_deployments)
#how many were not successful?
total<-num_all_deployments - num_successful_deployments
print(paste("Number of deployments with no captures:", total))
[1] "Number of deployments with no captures: 0"

So there were no failed deployments in the dataset - yay!

Sampling Period information

# checking for time NAs
print(sum(is.na(deployment$start_date)))
[1] 0
print(sum(is.na(deployment$end_date)))
[1] 0

No dates missing either - yay!

# Find the earliest start date
earliest_start_date <- min(deployment$start_date, na.rm = TRUE)

# Find the latest end date
latest_end_date <- max(deployment$end_date, na.rm = TRUE)

# View the results
print(paste("Earliest start date:", earliest_start_date))
[1] "Earliest start date: 2020-10-08"
print(paste("Latest end date:", latest_end_date))
[1] "Latest end date: 2021-10-31"
# Calculate the interval for each deployment
deployment$interval <- interval(deployment$start_date, deployment$end_date)

# If you want to calculate the duration in days, hours, etc.
deployment$duration_days <- as.numeric(deployment$interval) / (60 * 60 * 24)  # Convert to days

# Check the results
print(head(deployment[, c("start_date", "end_date", "duration_days")],5))
# A tibble: 5 × 3
  start_date          end_date            duration_days
  <dttm>              <dttm>                      <dbl>
1 2020-10-09 00:00:00 2021-10-20 00:00:00          376.
2 2020-10-08 00:00:00 2021-10-19 00:00:00          376.
3 2020-10-14 00:00:00 2021-10-12 00:00:00          363.
4 2020-10-09 00:00:00 2021-10-20 00:00:00          376.
5 2020-10-27 00:00:00 2021-10-13 00:00:00          351 

Lets look at a summary of the data spread too

summary(deployment$duration_days)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  348.0   352.0   367.0   364.3   375.5   376.0 

This data is quite evenly spread with only a small range between the minimum and maximum.

An important metric for reporting is survey effor so lets calculate that too.

# Sum the duration_days to calculate total camera days (sampling effort)
total_camera_days <- sum(deployment$duration_days, na.rm = TRUE)

# Round the result to NO decimal places
total_camera_days_rounded <- round(total_camera_days, 0)

# View the rounded result
print(paste("Total camera days (sampling effort):", total_camera_days_rounded))
[1] "Total camera days (sampling effort): 6921"

Camera trap locations

An important part of describing the data is the geographical context. lets make some!

Map creation

library(leaflet)

m <- leaflet() %>%             # call leaflet
        addTiles() %>%         # add the default basemap
        addMarkers(      # Add circles for stations
          lng=deployment$longitude, lat=deployment$latitude) 
m                              # return the map

Relative Abundance Index

To compare the relative abundance of animals in the sample we can calculate a relative index

event.sp <- function(camtraps, total_camera_days_rounded, time_threshold = NULL) {

  # A) No threshold → raw counts
  if (is.null(time_threshold)) {

    trapping_events <- camtraps %>%
      group_by(full_species, deployment_id) %>%
      summarise(trapping_event_count = n(), .groups = "drop")

  } else {

    # B) Threshold → independent events
    trapping_events <- camtraps %>%
      group_by(full_species, deployment_id) %>%
      arrange(timestamp, .by_group = TRUE) %>%
      mutate(
        time_diff = timestamp - lag(timestamp),
        new_event = if_else(is.na(time_diff) | time_diff > time_threshold, 1, 0)
      ) %>%
      summarise(trapping_event_count = sum(new_event), .groups = "drop")
  }

  # Add RAI
  if (length(total_camera_days_rounded) == 1) {

    trapping_events <- trapping_events %>%
      mutate(RIA = trapping_event_count / total_camera_days_rounded)

  } else if (is.data.frame(total_camera_days_rounded)) {

    trapping_events <- trapping_events %>%
      left_join(total_camera_days_rounded, by = "deployment_id") %>%
      mutate(RIA = trapping_event_count / total_camera_days_rounded)

  } else {
    stop("total_camera_days_rounded must be a single number or a data frame keyed by deployment_id.")
  }

  return(trapping_events)
}

And now create the tables to check them:

events_no_threshold <- event.sp(
  camtraps,
  total_camera_days_rounded,
  time_threshold = NULL
)

events_threshold <- event.sp(
  camtraps,
  total_camera_days_rounded,
  time_threshold = 30 * 60
)
summary_no_threshold <- events_no_threshold %>%
  group_by(full_species) %>%
  summarise(
    total_trapping_event_count = sum(trapping_event_count),
    total_RAI = sum(RIA),
    .groups = "drop"
  ) %>%
  mutate(type = "No threshold")

summary_threshold <- events_threshold %>%
  group_by(full_species) %>%
  summarise(
    total_trapping_event_count = sum(trapping_event_count),
    total_RAI = sum(RIA),
    .groups = "drop"
  ) %>%
  mutate(type = "30‑min threshold")

species_summary_combined <- bind_rows(
  summary_no_threshold,
  summary_threshold
)
# With a 30-minute threshold (in seconds)
trapping_events_with_threshold <- event.sp(
  camtraps,
  total_camera_days_rounded,
  time_threshold = 30 * 60
)

# Summarize results across all deployments
species_summary <- trapping_events_with_threshold %>%
  group_by(full_species) %>%
  summarise(
    total_trapping_event_count = sum(trapping_event_count, na.rm = TRUE),
    total_RAI = sum(RIA, na.rm = TRUE),
    .groups = 'drop'
  ) %>%
  arrange(desc(total_trapping_event_count))

# Print a nicely formatted table
kable(
  species_summary,
  format = "html",
  col.names = c("Species", "Total Trapping Events", "Total RAI"),
  caption = "Summary of Trapping Events and RAI by Species"
)
Summary of Trapping Events and RAI by Species
Species Total Trapping Events Total RAI
Martes caurina 1513 0.2186100
Tamiasciurus hudsonicus 139 0.0200838
Homo sapiens 104 0.0150267
Gulo gulo 91 0.0131484
Vulpes vulpes 72 0.0104031
Odocoileus hemionus 61 0.0088138
Cervus canadensis 54 0.0078023
Ursus americanus 49 0.0070799
Cervus elaphus 36 0.0052016
Perisoreus canadensis 32 0.0046236
Cyanocitta stelleri 31 0.0044791
Canis latrans 7 0.0010114
Poecile gambeli 6 0.0008669
Puma concolor 5 0.0007224
Canis familiaris 4 0.0005780
Glaucomys sabrinus 3 0.0004335
Lepus americanus 3 0.0004335
Picoides arcticus 3 0.0004335
Callospermophilus lateralis 2 0.0002890
Canis lupus 2 0.0002890
# Save and export this table
library(gt)

gt_table <- species_summary %>%
  rename(
    Species = full_species,
    `Total Trapping Events` = total_trapping_event_count,
    `Total RAI` = total_RAI
  ) %>%
  gt() %>%
  tab_header(
    title = "Summary of Trapping Events and RAI by Species"
  ) %>%
  cols_align(
    align = "center",
    columns = everything()
  ) %>%
  fmt_number(
    columns = `Total RAI`,
    decimals = 3
  )

gtsave(gt_table, "RAI.png")
file:///C:/Users/coope/AppData/Local/Temp/RtmpQf0MMS/file2c606bad7118.html screenshot completed
#checking my counts are correct

summary_threshold <- events_no_threshold %>%
  group_by(full_species) %>%
  summarise(
    total_trapping_event_count = sum(trapping_event_count, na.rm = TRUE),
    total_RAI = sum(RIA, na.rm = TRUE),
    .groups = "drop"
  ) %>%
  mutate(type = "30‑min threshold")


summary_no_threshold <- trapping_events_with_threshold %>%
  group_by(full_species) %>%
  summarise(
    total_trapping_event_count = sum(trapping_event_count, na.rm = TRUE),
    total_RAI = sum(RIA, na.rm = TRUE),
    .groups = "drop"
  ) %>%
  mutate(type = "No threshold")

species_summary_combined <- bind_rows(
  summary_threshold,
  summary_no_threshold
) %>%
  arrange(full_species, type)

and now ro produce the table I want for my presentation

target_species <- c(
  "Martes caurina",
  "Gulo gulo",
  "Vulpes vulpes",
  "Ursus americanus",
  "Canis latrans",
  "Canis lupus",
  "Canis familiaris"
)

comparison <- species_summary_combined %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = c(total_trapping_event_count, total_RAI),
    names_sep = "_"
  )

comparison_subset <- comparison %>%
  dplyr::filter(full_species %in% target_species) %>%
  dplyr::rename(
    `Full Species` = full_species,
    `Total Trapping Events` = `total_trapping_event_count_No threshold`,
    `RAI` = `total_RAI_No threshold`,
    `30‑min Threshold Trapping Events` = `total_trapping_event_count_30‑min threshold`,
    `RAI 30‑min Threshold` = `total_RAI_30‑min threshold`
  ) %>%
  dplyr::arrange(desc(`RAI 30‑min Threshold`)) %>%
  dplyr::select(
    `Full Species`,
    `Total Trapping Events`,
    `RAI`,
    `30‑min Threshold Trapping Events`,
    `RAI 30‑min Threshold`
  )

library(gt)

gt_table <- comparison_subset %>%
  gt() %>%
  tab_header(
    title = "Selected Species: Raw vs 30‑Minute Threshold Event Metrics"
  ) %>%
  cols_align(
    align = "center",
    columns = everything()
  ) %>%
  fmt_number(
    columns = c(`RAI`, `RAI 30‑min Threshold`),
    decimals = 2
  ) %>%
  fmt_number(
    columns = c(`Total Trapping Events`, `30‑min Threshold Trapping Events`),
    decimals = 0
  )

gtsave(
  gt_table,
  "C:/Users/coope/Documents/MSc Applied Ecology and Geospatial Techniques/Applied Pop Biol/wildlife-insights_240a773a-6a71-474a-ae0b-afed6661f231_all-platform-data/selected_species_table.png"
)
file:///C:/Users/coope/AppData/Local/Temp/RtmpQf0MMS/file2c6071f26def.html screenshot completed

Naive Occupancy

# Naive occupancy calculation
naive_occupancy <- camtraps %>%
  group_by(full_species, deployment_id) %>%
  summarise(detected = n() > 0, .groups = 'drop') %>%
  group_by(full_species) %>%
  summarise(
    number_of_positive_deployments = sum(detected),
    .groups = 'drop'
  ) %>%
  left_join(
    deployment %>% summarise(total_deployments = n_distinct(deployment_id)),
    by = character()
  ) %>%
  mutate(naive_occupancy = number_of_positive_deployments / total_deployments) %>%
  select(
    Species = full_species,
    number_of_positive_deployments,
    total_deployments,
    naive_occupancy
  ) %>%
  filter(Species %in% target_species) %>%
  arrange(desc(naive_occupancy))
Warning: Using `by = character()` to perform a cross join was deprecated in dplyr 1.1.0.
ℹ Please use `cross_join()` instead.
# Build GT table (corrected)
gt_table <- naive_occupancy %>%
  dplyr::rename(
    `Positive Deployments` = number_of_positive_deployments,
    `Total Deployments` = total_deployments,
    `Naive Occupancy` = naive_occupancy
  ) %>%
  gt() %>%
  tab_header(
    title = "Naive Occupancy Summary (Target Species)"
  ) %>%
  cols_align(
    align = "center",
    columns = everything()
  ) %>%
  fmt_number(
    columns = `Naive Occupancy`,
    decimals = 3
  )

# Export as PNG
gtsave(
  gt_table,
  "C:/Users/coope/Documents/MSc Applied Ecology and Geospatial Techniques/Applied Pop Biol/wildlife-insights_240a773a-6a71-474a-ae0b-afed6661f231_all-platform-data/naive_occupancy_table.png"
)
file:///C:/Users/coope/AppData/Local/Temp/RtmpQf0MMS/file2c60406a2992.html screenshot completed

This has given us an overview of the presence of species in the samples. Note that this is naive so no co-variates are utalised and no difference in detection is assessed. This is a good starting point as it shows the frequency of different species detections, helping to guide as we can see if there is sufficent data on the species of interest to continue.

We can map this data too:

library(dplyr)
library(ggplot2)
library(patchwork)

# 1. Filter to target species
camtraps_filtered <- camtraps %>%
  filter(full_species %in% target_species)

# 2. Count detections per species per deployment
counts <- camtraps_filtered %>%
  count(full_species, deployment_id, name = "n_detections") %>%
  left_join(
    deployment %>% select(deployment_id, longitude, latitude),
    by = "deployment_id"
  )

# 3. Extract species list
species_list <- unique(counts$full_species)

# 4. Create list to store plots
plot_list <- list()

# 5. Loop through species and build weighted maps
for (sp in species_list) {
  
  df <- counts %>% filter(full_species == sp)
  
  p <- ggplot(df, aes(longitude, latitude)) +
    geom_point(
      aes(size = n_detections),
      colour = "black",
      alpha = 0.7
    ) +
    scale_size(range = c(2, 12), guide = "none") +  # dot size = weighting
    coord_equal() +
    theme_minimal(base_size = 14) +
    labs(
      title = sp,        
      x = NULL,
      y = NULL
    ) +
    theme(
      plot.title = element_text(face = "bold", size = 16),
      axis.text = element_blank(),
      axis.ticks = element_blank()
    )
  
  plot_list[[sp]] <- p
}

# 6. Combine into a matrix layout (3 columns) with a global title
matrix_plot <- wrap_plots(plot_list, ncol = 3) +
  plot_annotation(
    title = "Detection Maps by Species",
    theme = theme(
      plot.title = element_text(size = 22, face = "bold", hjust = 0.5)
    )
  )

# 7. Export as a high‑resolution PNG
ggsave(
  filename = "species_detection_matrix_weighted.png",
  plot = matrix_plot,
  width = 14,
  height = 10,
  dpi = 300
)

matrix_plot

and as a combined map:

library(ggplot2)
# Extract species list directly from your RAI table
species_list <- comparison %>%
  distinct(full_species) %>%
  filter(full_species %in% target_species) %>%
  pull(full_species)

# Loop through each species
for (sp in species_list) {
  
  # Join detections for this species with total counts
  df <- camtraps %>%
    filter(full_species == sp) %>%
    left_join(
      comparison %>% 
        select(
          full_species,
          total_count = `total_trapping_event_count_30‑min threshold`
        ),
      by = "full_species"
    ) %>%
    left_join(
      deployment %>% select(deployment_id, longitude, latitude),
      by = "deployment_id"
    ) %>%
    distinct(deployment_id, longitude, latitude, total_count)
  
  # Plot heatmap for this species
  p <- ggplot(df, aes(longitude, latitude)) +
    stat_density_2d(
      aes(weight = total_count, fill = after_stat(level)),
      geom = "polygon",
      contour = TRUE,
      alpha = 0.7
    ) +
    scale_fill_viridis_c(option = "magma", guide = "none") +
    geom_jitter(
      aes(size = total_count),
      width = 0.002,
      height = 0.002,
      alpha = 0.6,
      colour = "white",
      show.legend = FALSE
    ) +
    coord_equal() +
    theme_minimal(base_size = 14) +
    labs(
      title = paste("Count Heatmap —", sp),
      x = NULL,
      y = NULL
    ) +
    theme(
      plot.title = element_text(face = "bold", size = 18),
      axis.text = element_blank(),
      axis.ticks = element_blank()
    )
  
  print(p)
}
Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight
Warning: Computation failed in `stat_density2d()`.
Caused by error in `precompute_2d_bw()`:
! The bandwidth argument `h` must contain numbers larger than 0.
ℹ Please set the `h` argument to stricly positive numbers manually.

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)), : Ignoring unknown aesthetics: weight
Computation failed in `stat_density2d()`.

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight

Warning in stat_density_2d(aes(weight = total_count, fill = after_stat(level)),
: Ignoring unknown aesthetics: weight

These are a nice selection of visuals showing that not all the species appear in all the sample sites. They are not that clear though so lets move on.

Occupancy Modeling Data Preparation

Adding Covariates

Elevation

library(elevatr)
elevatr v0.99.0 NOTE: Version 0.99.0 of 'elevatr' uses 'sf' and 'terra'.  Use 
of the 'sp', 'raster', and underlying 'rgdal' packages by 'elevatr' is being 
deprecated; however, get_elev_raster continues to return a RasterLayer.  This 
will be dropped in future versions, so please plan accordingly.
# Assuming deployment dataset contains 'longitude' and 'latitude' columns
coordinates <- data.frame(x = deployment$longitude, 
                          y = deployment$latitude)

# Get elevation data
elevation_data <- get_elev_point(coordinates, 
                                 prj = "EPSG:4326", #coordinate system Idaho Trans Merc, 
                                 src = "aws")# data source used for elevation
Mosaicing & Projecting
Note: Elevation units are in meters
# Add the elevation (in meters) as a new column to the deployment dataset
deployment$elevation <- elevation_data$elevation

Topographic Position Index

library(raster)# to use rasters
Loading required package: sp

Attaching package: 'raster'
The following object is masked from 'package:dplyr':

    select
library(sp)     # to manage spatial data
library(gstat)  # for geostatistical modelling

#Set correct CRS
idtm_crs <- CRS("+proj=tmerc +lat_0=42.5 +lon_0=-114 +k=0.9996 +x_0=2500000 +y_0=1200000 +datum=NAD83 +units=m +no_defs")

# Step 1: Create a SpatialPointsDataFrame, which combines
    # point coordinates and elevation in a single spatial object

coordinates_spdf <- SpatialPointsDataFrame(
  coords = coordinates,
  data = data.frame(elevation = elevation_data$elevation),
  proj4string = idtm_crs
)

# Step 2: Define a finer grid for interpolation to avoid gaps (adjust resolution)
# if the grid is too coarse, there will be gaps or strange patterns
grid_extent <- extent(coordinates_spdf)
grid <- expand.grid(
  x = seq(from = grid_extent@xmin, 
          to = grid_extent@xmax, 
          by = 0.005),  # Finer resolution
  y = seq(from = grid_extent@ymin, 
          to = grid_extent@ymax, 
          by = 0.005)
)
# and now creates a spatial object
coordinates_grid <- SpatialPoints(grid, proj4string = idtm_crs)

# Step 3: Perform kriging interpolation with more nearby points (nmax = 100)
kriging_model <- gstat(formula = elevation ~ 1, 
                       locations = coordinates_spdf, 
                       nmax = 100)
elevation_kriged <- predict(kriging_model, 
                            newdata = coordinates_grid)
[inverse distance weighted interpolation]
# Step 4: Convert the kriged result into a raster
elevation_raster <- rasterFromXYZ(as.data.frame(elevation_kriged)[, c("x", "y", "var1.pred")])

# Step 5: Calculate ruggedness using terrain function with 'tpi'
ruggedness <- terrain(elevation_raster, 
                      opt = "tpi", 
                      unit = "degrees")

# Step 6: Handle NA values: Interpolate use focal interpolation for missing values
ruggedness_filled <- focal(ruggedness, w = matrix(1, 3, 3), fun = mean, na.rm = TRUE, pad = TRUE)

# Step 7: Extract ruggedness values for each point
deployment$ruggedness <- extract(ruggedness_filled, coordinates_spdf)

# Replace NAs with median ruggedness
median_ruggedness <- median(deployment$ruggedness, na.rm = TRUE)
deployment$ruggedness[is.na(deployment$ruggedness)] <- median_ruggedness

Weather Data

# Read weather data
weather <- read.csv("weather.csv", stringsAsFactors = FALSE)
str(weather)
'data.frame':   10108 obs. of  23 variables:
 $ STATION  : chr  "USR0000OFLA" "USR0000OFLA" "USR0000OFLA" "USR0000OFLA" ...
 $ NAME     : chr  "FLAGSTAFF HILL OREGON, OR US" "FLAGSTAFF HILL OREGON, OR US" "FLAGSTAFF HILL OREGON, OR US" "FLAGSTAFF HILL OREGON, OR US" ...
 $ LATITUDE : num  44.8 44.8 44.8 44.8 44.8 ...
 $ LONGITUDE: num  -118 -118 -118 -118 -118 ...
 $ ELEVATION: num  1202 1202 1202 1202 1202 ...
 $ DATE     : chr  "2020-10-08" "2020-10-09" "2020-10-10" "2020-10-11" ...
 $ DAPR     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ MDPR     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ PRCP     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ SNOW     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ SNWD     : num  NA NA NA NA NA NA NA NA NA NA ...
 $ TAVG     : int  62 62 51 47 53 52 45 44 53 55 ...
 $ TMAX     : int  76 75 61 56 63 62 53 54 66 64 ...
 $ TMIN     : int  52 52 40 38 47 45 39 35 37 50 ...
 $ TOBS     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT01     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT02     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT03     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT04     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT05     : logi  NA NA NA NA NA NA ...
 $ WT06     : logi  NA NA NA NA NA NA ...
 $ WT08     : int  NA NA NA NA NA NA NA NA NA NA ...
 $ WT09     : logi  NA NA NA NA NA NA ...

Data collected from the National Centers for Environmental Information. Lets see how the sample sites compare to weather station locations:

#| label: comparing deplotments and eather station locations

# Extract unique weather stations
stations <- weather %>%
  dplyr::select(STATION, LATITUDE, LONGITUDE) %>%
  dplyr::distinct()

# Build map with both layers
m <- leaflet() %>%
  addTiles() %>%
  # Deployment sites
  addMarkers(
    data = deployment,
    lng = ~longitude,
    lat = ~latitude,
    popup = ~"Deployment site"
  ) %>%
  # Weather stations
  addCircleMarkers(
    data = stations,
    lng = ~LONGITUDE,
    lat = ~LATITUDE,
    popup = ~STATION,
    radius = 5,
    color = "blue",
    fillOpacity = 0.7
  )

m

There are more data points here than we need for weather stations, so lets filter that dataset to closest stations to sample locations.

library(sf)
Linking to GEOS 3.13.0, GDAL 3.10.1, PROJ 9.5.1; sf_use_s2() is TRUE
#| label: adding closest weather stations to deployment data

# Deployment sites
deployment_sf <- st_as_sf(deployment,
                          coords = c("longitude", "latitude"),
                          crs = 4326) %>%   # assume input is WGS84
  st_transform(2157)                        # convert to IDTM

# Weather stations
stations_sf <- weather %>%
  dplyr::select(STATION, LATITUDE, LONGITUDE) %>%
  dplyr::distinct() %>%
  st_as_sf(coords = c("LONGITUDE", "LATITUDE"),
           crs = 4326) %>%
  st_transform(2157)

nearest_idx <- st_nearest_feature(deployment_sf, stations_sf)

deployment_sf$nearest_station <- stations_sf$STATION[nearest_idx]
deployment_sf$distance_m <- st_distance(deployment_sf, stations_sf[nearest_idx, ], by_element = TRUE)

Elevation will affect the data for climate so comparing the elevation between weather station and sample locations would be a good idea

deployment_sf <- deployment_sf %>%
  # join station elevation from weather using nearest_station ID
  left_join(
    weather %>%
      dplyr::select(STATION, ELEVATION) %>%   # explicitly call dplyr::select
      dplyr::distinct(),
    by = c("nearest_station" = "STATION")
  ) %>%
  rename(station_elev = ELEVATION)

deployment_sf <- deployment_sf %>%
  mutate(
    # replace 'Elevation_m' with the actual site elevation column name
    elev_diff = elevation - station_elev
  )

add this data to the deployments:

deployment <- deployment %>%
  left_join(
    deployment_sf %>%
      st_drop_geometry() %>%
      dplyr::select(
        deployment_id,
        nearest_station,
        distance_to_station = distance_m,   # renamed here
        station_elev,
        elev_diff
      ),
    by = "deployment_id"
  )

Add weather station to the camtrap data

# Step 1: attach nearest_station from deployment metadata
camtraps <- camtraps %>%
  left_join(
    deployment %>% dplyr::select(deployment_id, nearest_station),
    by = "deployment_id"
  )

# Step 2: parse timestamp and extract date
camtraps <- camtraps %>%
  mutate(timestamp = ymd_hms(timestamp),
         date = as.Date(timestamp))
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `timestamp = ymd_hms(timestamp)`.
Caused by warning:
!  1 failed to parse.
# Step 3: ensure weather dates are Date type
weather <- weather %>%
  mutate(date = as.Date(DATE))

# Step 4: join camtraps to weather by nearest_station and date
camtraps <- camtraps %>%
  left_join(
    weather %>%
      rename(nearest_station = STATION) %>%   # align station column
      dplyr::select(nearest_station, date, PRCP, SNOW, SNWD, TAVG, TMAX, TMIN),
    by = c("nearest_station", "date")
  )
#| label: checking data coverage by species

env_vars <- c("PRCP", "SNOW", "SNWD", "TAVG", "TMAX", "TMIN")

na_pct_by_species <- camtraps %>%
  group_by(common_name) %>%
  summarise(
    across(all_of(env_vars),
           ~ mean(is.na(.)) * 100,   # percentage missing
           .names = "pct_na_{col}"),
    .groups = "drop"
  )

na_pct_by_species
# A tibble: 22 × 7
   common_name       pct_na_PRCP pct_na_SNOW pct_na_SNWD pct_na_TAVG pct_na_TMAX
   <chr>                   <dbl>       <dbl>       <dbl>       <dbl>       <dbl>
 1 American Black B…       87.5         91.7        92.2        92.9        92.9
 2 Black-backed Woo…      100          100          25         100         100  
 3 Coyote                   8.33       100           0           0           0  
 4 Domestic Dog           100          100         100         100         100  
 5 Elk                     59.4         99.5        48.6        48.6        48.6
 6 Golden Mantled G…        0            0         100         100         100  
 7 Grey Jay                44.3        100          44.3        44.3        44.3
 8 Grey Wolf                0           16.7       100         100         100  
 9 Homo Species            48.3        100          48.3        48.3        48.3
10 Human                   16.4         96.9        24.7        24.7        24.7
# ℹ 12 more rows
# ℹ 1 more variable: pct_na_TMIN <dbl>
# Overall % missing across all environment variables by deployment
na_pct_by_deployment <- camtraps %>%
  group_by(deployment_id) %>%
  summarise(
    pct_na_env = mean(is.na(across(all_of(env_vars)))) * 100,
    .groups = "drop"
  )

na_pct_by_deployment
# A tibble: 19 × 2
   deployment_id          pct_na_env
   <chr>                       <dbl>
 1 WM01.2                       99.4
 2 WM01.2 Ground                66.3
 3 WM03.2                       16.7
 4 WM03.2 Ground                97.5
 5 WM04.2                       67.1
 6 WM04.2 Ground                76.1
 7 WM06.2                       63.2
 8 WM06.2 Ground                68.8
 9 WM08.2                       51.6
10 WM08.2 Ground                64.6
11 WM09 10/29/2020              66.6
12 WM09 Ground 10/29/2020       70.0
13 WM10.2                       57.3
14 WM10.2 Ground                78.8
15 WM12.1                       16.7
16 WM12.1 Ground                17.7
17 WM13                         16.7
18 WM13.1 Ground                16.7
19 WM14 10/12/2020              76.3

There are a number of NAs in this data which could cause issues wiuth later processing. It will be important to be midful of this.

Time Covariates

Rather than building a relative datasaet like we have above, we only need the relative time of capture where we have captures, not the data for all deployments.

Workflow - add sunrise time, sunset time and relative time to both to the captraps data

library(suncalc)
library(activity)

# 1) Get local date per capture (no conversion needed)
camtraps_dates <- camtraps %>%
  mutate(date = as.Date(timestamp)) %>%
  dplyr::select(deployment_id, date) %>%
  distinct()

# 2) Bring lat/lon per deployment_id
site_coords <- deployment %>%
  dplyr::select(deployment_id, latitude, longitude) %>%
  rename(lat = latitude, lon = longitude)

coords <- camtraps_dates %>%
  left_join(site_coords, by = "deployment_id")

# 3) Compute sunrise/sunset for capture dates only
sun_times <- getSunlightTimes(
  data = coords %>% dplyr::select(lat, lon, date),
  keep = c("sunrise", "sunset"),
  tz = "America/Los_Angeles"
)

# Add deployment_id back in from coords
sun_times <- bind_cols(coords %>% dplyr::select(deployment_id), sun_times)

# 4) Join sunrise/sunset AND lat/lon back to camtraps
camtraps_with_sun <- camtraps %>%
  mutate(date = as.Date(timestamp)) %>%
  left_join(sun_times %>% dplyr::select(deployment_id, date, sunrise, sunset),
            by = c("deployment_id", "date")) %>%
  left_join(site_coords, by = "deployment_id")   # ensures lat/lon per capture

# 5) Compute corrected solar time (radians)
tmp <- solartime(
  camtraps_with_sun$timestamp,
  camtraps_with_sun$lat,
  camtraps_with_sun$lon,
  tz = 0   # use 0 since timestamps are already local
)

# 6) Add solar time in hours and clock time in hours
camtraps_with_sun <- camtraps_with_sun %>%
  mutate(
    solar       = tmp$solar,
    solar_hours = solar * 24 / (2 * pi),
    clock_hours = as.numeric(format(timestamp, "%H")) +
                  as.numeric(format(timestamp, "%M")) / 60 +
                  as.numeric(format(timestamp, "%S")) / 3600
  )

# 7) Normalise differences to [-12, +12]
normalize_diff <- function(x) {
  x <- ifelse(x > 12, x - 24, x)
  x <- ifelse(x < -12, x + 24, x)
  return(x)
}

camtraps_with_sun <- camtraps_with_sun %>%
  mutate(diff = normalize_diff(clock_hours - solar_hours))

Export and save files

This now brings us to the completed datasets for analysis, lets slim and save

names(deployment)
 [1] "project_id"                 "deployment_id"             
 [3] "longitude"                  "latitude"                  
 [5] "start_date"                 "end_date"                  
 [7] "bait_type"                  "bait_description"          
 [9] "feature_type"               "feature_type_methodology"  
[11] "camera_id"                  "camera_name"               
[13] "quiet_period"               "camera_functioning"        
[15] "sensor_height"              "height_other"              
[17] "sensor_orientation"         "orientation_other"         
[19] "plot_treatment"             "plot_treatment_description"
[21] "detection_distance"         "subproject_name"           
[23] "subproject_design"          "event_name"                
[25] "event_description"          "event_type"                
[27] "recorded_by"                "fuzzed"                    
[29] "deployment_fuzzed"          "interval"                  
[31] "duration_days"              "elevation"                 
[33] "ruggedness"                 "nearest_station"           
[35] "distance_to_station"        "station_elev"              
[37] "elev_diff"                 
deployment_subset <- deployment[, c("deployment_id", 
                                     "longitude", 
                                     "latitude", 
                                     "start_date", 
                                     "end_date", 
                                     "camera_id",
                                     "sensor_height",
                                     "elevation", 
                                     "ruggedness")]
# save the dataset as csv file
write.csv(deployment_subset, 
          "deployment+covariates.csv", 
          row.names = FALSE)
# save the dataset as csv file
write.csv(camtraps_with_sun, 
          "images+covariates.csv", 
          row.names = FALSE)
rm(list = ls())
# Detach all non-base packages
detach_all_packages <- function() {
  basic.packages <- c("package:stats", "package:graphics", "package:grDevices",
                      "package:utils", "package:datasets", "package:methods", "package:base")
  
  loaded <- search()[grepl("^package:", search())]
  to.detach <- setdiff(loaded, basic.packages)
  
  for(pkg in to.detach) {
    detach(pkg, character.only = TRUE, unload = TRUE)
  }
}

# Run it
detach_all_packages()
Warning: 'sp' namespace cannot be unloaded:
  namespace 'sp' is imported by 'spacetime', 'raster' so cannot be unloaded
Warning: 'knitr' namespace cannot be unloaded:
  namespace 'knitr' is imported by 'rmarkdown' so cannot be unloaded
Warning: 'dplyr' namespace cannot be unloaded:
  namespace 'dplyr' is imported by 'tidyr' so cannot be unloaded

Occupancy Model of the Pacfic Marten (winter only)

Now this has been done, we can start to investigate and prepare for occupancy modeling. I am going to look at the Pacific marten due to a high number of sampling events and a wide range of co variate availability.

library(readr)
library(lubridate)

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(knitr)
library(kableExtra)

Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':

    group_rows
library(tidyr)
#| label: Calling the marten Data

deployments<-read.csv("deployment+covariates.csv")
marten_img<-read.csv("images+covariates.csv")%>%
  filter(genus == "Martes")

In this data, effort is constant so it is not needed as a co variate (all deployments were the same)

# Step 1: Convert start_date and end_date to Date format
deployments$start_date <- as.Date(deployments$start_date, format = "%Y-%m-%d")
deployments$end_date   <- as.Date(deployments$end_date,   format = "%Y-%m-%d")

# Step 2: Expand deployments into daily records
deployments_days <- deployments %>%
  rowwise() %>%
  mutate(day_seq = list(seq.Date(start_date, end_date, by = "day"))) %>%
  ungroup() %>%
  dplyr::select(deployment_id, day_seq) %>%
  tidyr::unnest(day_seq)

# Step 3: Assign each day to a biologically relevant season
deployment_subset <- deployments_days %>%
  mutate(month = month(day_seq),
         season = case_when(
           month %in% 7:8                  ~ "Breeding",               # Jul–Aug
           month %in% 3:6                  ~ "Birthing/raising young", # Mar–Jun
           month %in% 9:10                 ~ "Dispersal",              # Sep–Oct
           month %in% c(11,12,1,2)         ~ "Winter survival",        # Nov–Feb
           TRUE ~ NA_character_
         ))

# Step 4: Filter daily records for Winter survival season (Nov–Feb)
winter_days <- deployment_subset %>%
  filter(season == "Winter survival")

# Step 5: Collapse back to deployments (Winter only)
deployment_data <- winter_days %>%
  group_by(deployment_id) %>%
  summarise(start_date = min(day_seq),
            end_date   = max(day_seq),
            .groups = "drop")

# Step 6: Define global study period and partition length
overall_start_date <- min(deployment_data$start_date)
overall_end_date   <- max(deployment_data$end_date)
period_length <- 5
total_periods <- ceiling(as.numeric(difftime(overall_end_date, overall_start_date, units = "days")) / period_length)

# Step 7: Create dynamic SO columns
so_columns <- paste0("SO", 1:total_periods)

so_df <- data.frame(deployment_id = character(),
                    matrix(NA, nrow = 0, ncol = total_periods),
                    start_date = as.Date(character()),
                    end_date   = as.Date(character()),
                    stringsAsFactors = FALSE)

colnames(so_df)[2:(total_periods+1)] <- so_columns

# Step 8: Loop through deployments and mark periods (1 if overlaps, 0 otherwise)
for (index in 1:nrow(deployment_data)) {
  deployment_id <- deployment_data$deployment_id[index]
  start_date    <- deployment_data$start_date[index]
  end_date      <- deployment_data$end_date[index]
  
  period_flags <- rep(0, total_periods)
  
  for (period in 0:(total_periods-1)) {
    period_start <- overall_start_date + days(period * period_length)
    period_end   <- period_start + days(period_length - 1)
    
    if (period_end >= start_date && period_start <= end_date) {
      period_flags[period + 1] <- 1
    }
  }
  
  # Name the flags with SO column names
  period_flags <- setNames(as.list(period_flags), so_columns)
  
  # Append row with proper names
  so_df <- rbind(so_df,
                 data.frame(deployment_id = deployment_id,
                            start_date = start_date,
                            end_date = end_date,
                            period_flags,
                            stringsAsFactors = FALSE))
}

so_df <- so_df %>% arrange(start_date)

# Step 9: Inspect first few rows
head(so_df, 10)
   deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9 SO10
1         WM01.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
2  WM01.2 Ground 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
3         WM03.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
4  WM03.2 Ground 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
5         WM04.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
6  WM04.2 Ground 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
7         WM06.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
8  WM06.2 Ground 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
9         WM08.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
10 WM08.2 Ground 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
   SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1

##Build the Detection Matrix LOOK HERE FOR THE NEXT ISSUE - NAs IN THE MATRIX!!!!

# Step 1: Make sure detection timestamps are in Date format
marten_img <- marten_img %>%
  mutate(timestamp = as.Date(timestamp, format = "%Y-%m-%d"))

# Step 2: Build lookup table of SO block ranges
so_blocks <- data.frame()
for (period in 0:(ncol(so_df)-3)) {   # subtract deployment_id, start_date, end_date
  period_start <- min(so_df$start_date) + days(period * 5)
  period_end   <- period_start + days(4)
  so_blocks <- rbind(so_blocks,
                     data.frame(SO = paste0("SO", period+1),
                                block_start = period_start,
                                block_end   = period_end))
}

# Step 3: For each deployment × SO, check if detections fall in that block
detection_matrix <- so_df
for (so in so_blocks$SO) {
  block_start <- so_blocks$block_start[so_blocks$SO == so]
  block_end   <- so_blocks$block_end[so_blocks$SO == so]
  
  detection_matrix[[so]] <- mapply(function(dep_id, start_date, end_date) {
    any(marten_img$deployment_id == dep_id &
        marten_img$timestamp >= block_start &
        marten_img$timestamp <= block_end)
  }, detection_matrix$deployment_id,
     detection_matrix$start_date,
     detection_matrix$end_date)
  
  # Convert logical TRUE/FALSE to 1/0
  detection_matrix[[so]] <- as.integer(detection_matrix[[so]])
}

# Step 4: Inspect first few rows
head(detection_matrix, 10)
   deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9 SO10
1         WM01.2 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
2  WM01.2 Ground 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
3         WM03.2 2020-11-01 2021-02-28   1   1   1   0   0   0   0   0   0    0
4  WM03.2 Ground 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
5         WM04.2 2020-11-01 2021-02-28   1   0   0   1   1   1   1   0   1    1
6  WM04.2 Ground 2020-11-01 2021-02-28   0   0   0   1   1   1   1   0   0    0
7         WM06.2 2020-11-01 2021-02-28   1   1   0   1   1   1   0   1   0    1
8  WM06.2 Ground 2020-11-01 2021-02-28   1   1   1   1   0   1   1   0   0    0
9         WM08.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
10 WM08.2 Ground 2020-11-01 2021-02-28   1   0   0   0   0   0   0   0   0    0
   SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24 SO25
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     1    1    0    0    0    0    0    0    0    0    0    0    0    0    0
6     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    1    0    0    1    0    0    0    0    0    0    0    0    0    0
8     0    1    1    1    1    0    1    0    0    1    0    0    0    0    0
9     1    0    1    1    1    0    1    0    1    1    1    0    1    0    1
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
sum(is.na(detection_matrix))
[1] 16

This has generated some NAs in the deployments WM13, so lets remove these

# Remove the WM13 row
detection_matrix_new <- detection_matrix[!grepl("WM13", rownames(detection_matrix)), ]

# Replace all NAs with 0
detection_matrix_new[is.na(detection_matrix_new)] <- 0

ok and add the deployment covariates

Add Deployment Covariates

# Step 1: Select the covariates you want from deployments
deployment_covariates <- deployments %>%
  dplyr::select(deployment_id, sensor_height, elevation, ruggedness)

# Step 2: Join them into your detection_matrix
detection_matrix <- detection_matrix %>%
  left_join(deployment_covariates, by = "deployment_id")

# Step 3: Recode sensor_height: Other = 0, Chest Height = 1, NA treated as Chest Height (1)
detection_matrix$sensor_height_num <- ifelse(is.na(detection_matrix$sensor_height), 1,
                                      ifelse(detection_matrix$sensor_height == "Other", 0, 1))

# Step 4: Inspect the first few rows
head(detection_matrix, 10)
   deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9 SO10
1         WM01.2 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
2  WM01.2 Ground 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
3         WM03.2 2020-11-01 2021-02-28   1   1   1   0   0   0   0   0   0    0
4  WM03.2 Ground 2020-11-01 2021-02-28   0   0   0   0   0   0   0   0   0    0
5         WM04.2 2020-11-01 2021-02-28   1   0   0   1   1   1   1   0   1    1
6  WM04.2 Ground 2020-11-01 2021-02-28   0   0   0   1   1   1   1   0   0    0
7         WM06.2 2020-11-01 2021-02-28   1   1   0   1   1   1   0   1   0    1
8  WM06.2 Ground 2020-11-01 2021-02-28   1   1   1   1   0   1   1   0   0    0
9         WM08.2 2020-11-01 2021-02-28   1   1   1   1   1   1   1   1   1    1
10 WM08.2 Ground 2020-11-01 2021-02-28   1   0   0   0   0   0   0   0   0    0
   SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24 SO25
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     1    1    0    0    0    0    0    0    0    0    0    0    0    0    0
6     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    1    0    0    1    0    0    0    0    0    0    0    0    0    0
8     0    1    1    1    1    0    1    0    0    1    0    0    0    0    0
9     1    0    1    1    1    0    1    0    1    1    1    0    1    0    1
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   sensor_height elevation ruggedness sensor_height_num
1          Other      2311  -2.082459                 0
2   Chest height      2311  -2.082459                 1
3          Other      2402   2.864809                 0
4   Chest height      2402   2.864809                 1
5          Other      2209  -2.627357                 0
6   Chest height      2209  -2.627357                 1
7          Other      2459   4.051330                 0
8   Chest height      2459   4.051330                 1
9          Other      2459   3.099113                 0
10         Other      2459   3.099113                 0

adding sample specific covariats and changing data for model

Add Sample Covariates

There were a lot of NAs in the weather data, to help with this snowdepth is going to be changed to a presence/absence binary variable.

# Step 1: Pivot detection_matrix into long format (deployment × SO occasion)
detection_long <- detection_matrix %>%
  pivot_longer(
    cols = starts_with("SO"),
    names_to = "SO",
    values_to = "detection"
  )

# Step 2: Assign each timestamp to an SO block
marten_img <- marten_img %>%
  mutate(
    SO = paste0(
      "SO",
      floor(as.numeric(difftime(timestamp, min(detection_matrix$start_date), units = "days")) / 5) + 1
    )
  )

# Step 3: Aggregate covariates by deployment × SO (mean values per block)
sample_covariates <- marten_img %>%
  group_by(deployment_id, SO) %>%
  summarise(
    PRCP = mean(PRCP, na.rm = TRUE),
    SNOW = mean(SNOW, na.rm = TRUE),
    SNWD = mean(SNWD, na.rm = TRUE),
    TAVG = mean(TAVG, na.rm = TRUE),
    TMAX = mean(TMAX, na.rm = TRUE),
    TMIN = mean(TMIN, na.rm = TRUE),
    .groups = "drop"
  )

# Step 4: Join sample-level covariates into detection_long
detection_long <- detection_long %>%
  left_join(sample_covariates, by = c("deployment_id", "SO"))

# convert SNWD to binary presence/absence (treat NA as 0 = no snow)
detection_long$SNWD <- ifelse(is.na(detection_long$SNWD), 0,
                              ifelse(detection_long$SNWD > 0, 1, 0))

# Step 5: Inspect
head(detection_long, 10)
# A tibble: 10 × 15
   deployment_id start_date end_date   sensor_height elevation ruggedness
   <chr>         <date>     <date>     <chr>             <int>      <dbl>
 1 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 2 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 3 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 4 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 5 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 6 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 7 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 8 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
 9 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
10 WM01.2        2020-11-01 2021-02-28 Other              2311      -2.08
# ℹ 9 more variables: sensor_height_num <dbl>, SO <chr>, detection <int>,
#   PRCP <dbl>, SNOW <dbl>, SNWD <dbl>, TAVG <dbl>, TMAX <dbl>, TMIN <dbl>

This gives us the fully integrated data set! Yay!

# Extract detection history (matrix of 1/0)
y <- detection_matrix %>%
  select(starts_with("SO")) %>%
  as.matrix()
# Use the same overall_start_date and total_periods you defined earlier
overall_start_date <- min(detection_matrix$start_date)
period_length <- 5
total_periods <- ncol(y)   # should be 25
print(ncol(y))
[1] 25
# Assign SO blocks consistently
marten_img <- marten_img %>%
  mutate(SO = paste0(
    "SO",
    floor(as.numeric(difftime(timestamp, overall_start_date, units = "days")) / period_length) + 1
  ))

# Summarise covariates per deployment × SO
obs_covs_long <- marten_img %>%
  group_by(deployment_id, SO) %>%
  summarise(
    PRCP = mean(PRCP, na.rm = TRUE),
    SNOW = mean(SNOW, na.rm = TRUE),
    SNWD = mean(SNWD, na.rm = TRUE),
    TAVG = mean(TAVG, na.rm = TRUE),
    TMAX = mean(TMAX, na.rm = TRUE),
    TMIN = mean(TMIN, na.rm = TRUE),
    .groups = "drop"
  )

# Build complete grid of deployment × SO
so_cols <- colnames(y)
dep_order <- detection_matrix$deployment_id
complete_grid <- expand.grid(
  deployment_id = dep_order,
  SO = so_cols,
  stringsAsFactors = FALSE
)

obs_covs_complete <- complete_grid %>%
  left_join(obs_covs_long, by = c("deployment_id", "SO"))

# Convert SNWD to binary presence/absence (treat NA as 0)
obs_covs_complete$SNWD <- ifelse(
  is.na(obs_covs_complete$SNWD), 0,
  ifelse(obs_covs_complete$SNWD > 0, 1, 0)
)

# Convert PRCP to binary presence/absence (treat NA as 0)
obs_covs_complete$PRCP <- ifelse(
  is.na(obs_covs_complete$PRCP), 0,
  ifelse(obs_covs_complete$PRCP > 0, 1, 0)
)

# Convert SNOW to binary presence/absence (treat NA as 0)
obs_covs_complete$SNOW <- ifelse(
  is.na(obs_covs_complete$SNOW), 0,
  ifelse(obs_covs_complete$SNOW > 0, 1, 0)
)

# Interpolate TAVG, TMAX, TMIN within each deployment
obs_covs_complete <- obs_covs_complete %>%
  group_by(deployment_id) %>%
  mutate(
    TAVG = zoo::na.approx(TAVG, na.rm = FALSE, rule = 2),
    TMAX = zoo::na.approx(TMAX, na.rm = FALSE, rule = 2),
    TMIN = zoo::na.approx(TMIN, na.rm = FALSE, rule = 2)
  ) %>%
  ungroup()

# Pivot each covariate into a 19 × 25 matrix
make_obs_matrix <- function(df, value_col) {
  wide <- df %>%
    select(deployment_id, SO, !!sym(value_col)) %>%
    pivot_wider(names_from = SO, values_from = !!sym(value_col))
  wide <- wide %>% slice(match(dep_order, deployment_id))
  as.matrix(wide[, so_cols])
}

obs_covs_list <- list(
  PRCP = make_obs_matrix(obs_covs_complete, "PRCP"),
  SNOW = make_obs_matrix(obs_covs_complete, "SNOW"),
  SNWD = make_obs_matrix(obs_covs_complete, "SNWD"),
  TAVG = make_obs_matrix(obs_covs_complete, "TAVG"),
  TMAX = make_obs_matrix(obs_covs_complete, "TMAX"),
  TMIN = make_obs_matrix(obs_covs_complete, "TMIN")
)

dim(y)
[1] 19 25
lapply(obs_covs_list, dim)
$PRCP
[1] 19 25

$SNOW
[1] 19 25

$SNWD
[1] 19 25

$TAVG
[1] 19 25

$TMAX
[1] 19 25

$TMIN
[1] 19 25

Within this chunk I have interpolated the missing temperature data and changed SNOW and PRCP to binary values. This is to help the model running and to increase he biological validity of our results.

Correlation between site covariates

site_covs <- deployment_covariates[, c("elevation", "ruggedness", "sensor_height")]

# Recode sensor_height: Other = 0, Chest Height = 1, NA treated as Chest Height (1)
site_covs$sensor_height <- ifelse(is.na(site_covs$sensor_height), 1,
                           ifelse(site_covs$sensor_height == "Other", 0, 1))

# Now everything is numeric
cor(site_covs, use = "pairwise.complete.obs")
               elevation ruggedness sensor_height
elevation     1.00000000  0.9294703    0.01398884
ruggedness    0.92947029  1.0000000    0.07965490
sensor_height 0.01398884  0.0796549    1.00000000

This is telling us that the elevation and ruggedness are highly correlated 92.9%, with sensor height not correlated with either.

library(Hmisc)
Overwriting method +(<ggplot2::ggplot>, <ANY>)
Overwriting method +(<ggplot2::theme>, <ANY>)
Overwriting method convert(<ggplot2::ggplot>, <list>)

Attaching package: 'Hmisc'
The following objects are masked from 'package:dplyr':

    src, summarize
The following objects are masked from 'package:base':

    format.pval, units
covs <- obs_covs_complete %>%
  select(PRCP, SNOW, SNWD, TAVG, TMAX, TMIN)

res <- rcorr(as.matrix(covs), type = "pearson")

res$r
            PRCP       SNOW        SNWD        TAVG        TMAX      TMIN
PRCP  1.00000000 0.29666381  0.72870708  0.01622703 -0.05207178 0.1389199
SNOW  0.29666381 1.00000000  0.09833121          NA          NA        NA
SNWD  0.72870708 0.09833121  1.00000000 -0.03284606 -0.01294908 0.0826881
TAVG  0.01622703         NA -0.03284606  1.00000000  0.86827845 0.8978266
TMAX -0.05207178         NA -0.01294908  0.86827845  1.00000000 0.6981778
TMIN  0.13891986         NA  0.08268810  0.89782655  0.69817785 1.0000000
res$P
             PRCP         SNOW       SNWD      TAVG      TMAX       TMIN
PRCP           NA 4.175682e-11 0.00000000 0.7884084 0.3888306 0.02096351
SNOW 4.175682e-11           NA 0.03214303        NA        NA         NA
SNWD 0.000000e+00 3.214303e-02         NA 0.5868890 0.8304231 0.17073992
TAVG 7.884084e-01           NA 0.58688898        NA 0.0000000 0.00000000
TMAX 3.888306e-01           NA 0.83042312 0.0000000        NA 0.00000000
TMIN 2.096351e-02           NA 0.17073992 0.0000000 0.0000000         NA
res$n
     PRCP SNOW SNWD TAVG TMAX TMIN
PRCP  475  475  475  276  276  276
SNOW  475  475  475  276  276  276
SNWD  475  475  475  276  276  276
TAVG  276  276  276  276  276  276
TMAX  276  276  276  276  276  276
TMIN  276  276  276  276  276  276
print(res$r)
            PRCP       SNOW        SNWD        TAVG        TMAX      TMIN
PRCP  1.00000000 0.29666381  0.72870708  0.01622703 -0.05207178 0.1389199
SNOW  0.29666381 1.00000000  0.09833121          NA          NA        NA
SNWD  0.72870708 0.09833121  1.00000000 -0.03284606 -0.01294908 0.0826881
TAVG  0.01622703         NA -0.03284606  1.00000000  0.86827845 0.8978266
TMAX -0.05207178         NA -0.01294908  0.86827845  1.00000000 0.6981778
TMIN  0.13891986         NA  0.08268810  0.89782655  0.69817785 1.0000000

So this is telling us that: - only one temperature variable should be used for modelling - precipitation and snow depth should not be combined

Unmarked object creation

library(unmarked)

marten <- unmarkedFrameOccu(
  y = y,
  siteCovs = deployment_covariates,
  obsCovs = obs_covs_list
)
Warning: siteCovs contains characters. Converting them to factors.
# Inspect
marten
Data frame representation of unmarkedFrame object.
   y.1 y.2 y.3 y.4 y.5 y.6 y.7 y.8 y.9 y.10 y.11 y.12 y.13 y.14 y.15 y.16 y.17
1    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
2    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
3    1   1   1   0   0   0   0   0   0    0    0    0    0    0    0    0    0
4    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
5    1   0   0   1   1   1   1   0   1    1    1    1    0    0    0    0    0
6    0   0   0   1   1   1   1   0   0    0    1    0    0    0    0    0    0
7    1   1   0   1   1   1   0   1   0    1    0    1    0    0    1    0    0
8    1   1   1   1   0   1   1   0   0    0    0    1    1    1    1    0    1
9    1   1   1   1   1   1   1   1   1    1    1    0    1    1    1    0    1
10   1   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
11   0   0   0   1   1   1   1   1   1    0    1    1    1    1    0    0    0
12   0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    1    0
13   1   1   1   1   0   0   0   0   0    0    0    0    0    0    0    1    1
14   1   1   1   0   0   0   0   0   0    0    0    0    0    0    0    1    1
15   1   1   1   1   1   1   1   0   0    0    1    0    0    0    1    1    0
16   0   0   1   1   1   1   1   1   0    0    1    0    0    0    0    1    0
17   1   1   1   1   1   1   1   1  NA    1    1   NA   NA   NA   NA    1    1
18   1   1   1   1   1   1   1   1  NA    1    1    1   NA   NA   NA    1    1
19   0   0   1   1   1   0   0   1   0    1    1    0    0    0    1    0    1
   y.18 y.19 y.20 y.21 y.22 y.23 y.24 y.25          deployment_id sensor_height
1     0    0    0    0    0    0    0    1                 WM08.2         Other
2     0    0    0    0    0    0    0    0          WM01.2 Ground  Chest height
3     0    0    0    0    0    0    0    0                 WM12.1         Other
4     0    0    0    0    0    0    0    0          WM08.2 Ground         Other
5     0    0    0    0    0    0    0    0          WM13.1 Ground  Chest height
6     0    0    0    0    0    0    0    0 WM09 Ground 10/29/2020  Chest height
7     0    0    0    0    0    0    0    0        WM09 10/29/2020         Other
8     0    0    1    0    0    0    0    0                 WM04.2         Other
9     0    1    1    1    0    1    0    1                   WM13         Other
10    0    0    0    0    0    0    0    0          WM12.1 Ground  Chest height
11    1    0    0    0    0    0    0    1                 WM10.2         Other
12    0    0    0    0    0    0    0    0          WM10.2 Ground  Chest height
13    1    0    0    0    0    0    0    0                 WM01.2         Other
14    1    0    0    0    0    0    0    0                 WM03.2         Other
15    0    0    0    0    0    0    0    0          WM03.2 Ground  Chest height
16    1    0    0    0    0    0    0    0          WM04.2 Ground  Chest height
17    1   NA    1    1    1   NA   NA   NA          WM06.2 Ground  Chest height
18    1    1    1    1    1   NA   NA   NA                 WM06.2         Other
19    0    0    0    0    0    0    0    1        WM14 10/12/2020         Other
   elevation  ruggedness PRCP.1 PRCP.2 PRCP.3 PRCP.4 PRCP.5 PRCP.6 PRCP.7
1       2459   3.0991125      0      0      0      0      0      0      0
2       2311  -2.0824588      0      0      0      0      0      0      0
3       2375   1.7593043      0      1      1      0      0      0      0
4       2459   3.0991125      0      0      0      0      0      0      0
5       2255  -1.1037417      0      0      0      0      1      0      0
6       2173  -0.8553052      0      0      0      0      1      0      0
7       2173  -0.8553052      0      1      0      1      1      0      0
8       2209  -2.6273567      0      1      1      1      0      0      0
9       2255  -1.1037417      0      1      1      1      1      0      0
10      2375   1.7593043      0      0      0      0      0      0      0
11      2173  -2.2429066      0      0      0      1      1      1      1
12      2173  -2.2429066      0      0      0      0      0      0      0
13      2311  -2.0824588      0      1      1      1      0      0      0
14      2402   2.8648094      0      1      1      0      0      0      0
15      2402   2.8648094      0      1      1      1      1      1      0
16      2209  -2.6273567      0      0      1      0      1      1      1
17      2459   4.0513298      0      1      1      1      0      0      1
18      2459   4.0513298      0      1      1      1      0      1      1
19      1923 -13.0963227      0      0      1      1      1      0      0
   PRCP.8 PRCP.9 PRCP.10 PRCP.11 PRCP.12 PRCP.13 PRCP.14 PRCP.15 PRCP.16
1       0      0       0       0       0       0       0       0       0
2       0      0       0       0       0       0       0       0       0
3       0      0       0       0       0       0       0       0       0
4       0      0       0       0       0       0       0       0       0
5       0      0       1       1       1       0       0       0       0
6       0      0       0       0       0       0       0       0       0
7       0      0       0       0       0       0       0       0       0
8       0      0       0       0       0       0       0       0       0
9       0      0       0       0       0       0       0       0       0
10      0      0       0       0       0       0       0       0       0
11      0      0       0       0       1       1       1       0       0
12      0      0       0       0       0       0       0       0       0
13      0      0       0       0       0       0       0       0       0
14      0      0       0       0       0       0       0       0       0
15      0      0       0       0       0       0       0       1       1
16      0      0       0       1       0       0       0       0       0
17      0      0       1       1       0       0       0       0       1
18      0      0       1       1       1       0       0       0       1
19      0      0       0       0       0       0       0       0       0
   PRCP.17 PRCP.18 PRCP.19 PRCP.20 PRCP.21 PRCP.22 PRCP.23 PRCP.24 PRCP.25
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       1       0       0       0       0       0       0       0
17       1       1       0       0       1       1       0       0       0
18       1       1       0       0       1       1       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.1 SNOW.2 SNOW.3 SNOW.4 SNOW.5 SNOW.6 SNOW.7 SNOW.8 SNOW.9 SNOW.10
1       0      0      0      0      0      0      0      0      0       0
2       0      0      0      0      0      0      0      0      0       0
3       0      0      0      0      0      0      0      0      0       0
4       0      0      0      0      0      0      0      0      0       0
5       0      0      0      0      1      0      0      0      0       0
6       0      0      0      0      1      0      0      0      0       0
7       0      0      0      0      0      0      0      0      0       0
8       0      0      0      0      0      0      0      0      0       0
9       0      0      0      0      0      0      0      0      0       0
10      0      0      0      0      0      0      0      0      0       0
11      0      0      0      0      1      1      0      0      0       0
12      0      0      0      0      0      0      0      0      0       0
13      0      0      0      0      0      0      0      0      0       0
14      0      0      0      0      0      0      0      0      0       0
15      0      0      0      0      0      0      0      0      0       0
16      0      0      0      0      0      0      0      0      0       0
17      0      0      0      0      0      0      0      0      0       0
18      0      0      0      0      0      0      0      0      0       0
19      0      0      0      0      0      0      0      0      0       0
   SNOW.11 SNOW.12 SNOW.13 SNOW.14 SNOW.15 SNOW.16 SNOW.17 SNOW.18 SNOW.19
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       1       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       1       0       1       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.20 SNOW.21 SNOW.22 SNOW.23 SNOW.24 SNOW.25 SNWD.1 SNWD.2 SNWD.3 SNWD.4
1        0       0       0       0       0       0      0      0      0      0
2        0       0       0       0       0       0      0      0      0      0
3        0       0       0       0       0       0      0      1      1      0
4        0       0       0       0       0       0      0      0      0      0
5        0       0       0       0       0       0      0      0      0      0
6        0       0       0       0       0       0      0      0      0      0
7        0       0       0       0       0       0      0      1      0      0
8        0       0       0       0       0       0      0      1      1      0
9        0       0       0       0       0       0      0      1      1      0
10       0       0       0       0       0       0      0      0      0      0
11       0       0       0       0       0       0      0      0      0      1
12       0       0       0       0       0       0      0      0      0      0
13       0       0       0       0       0       0      0      1      1      0
14       0       0       0       0       0       0      0      0      1      0
15       0       0       0       0       0       0      0      1      1      1
16       0       0       0       0       0       0      0      0      1      1
17       0       0       0       0       0       0      0      1      1      1
18       0       0       0       0       0       0      0      1      1      1
19       0       0       0       0       0       0      0      0      1      0
   SNWD.5 SNWD.6 SNWD.7 SNWD.8 SNWD.9 SNWD.10 SNWD.11 SNWD.12 SNWD.13 SNWD.14
1       0      0      0      0      0       0       0       0       0       0
2       0      0      0      0      0       0       0       0       0       0
3       0      0      0      0      0       0       0       0       0       0
4       0      0      0      0      0       0       0       0       0       0
5       0      0      0      0      0       0       0       1       0       0
6       0      0      0      0      0       0       0       0       0       0
7       0      0      0      0      0       0       0       0       0       0
8       0      0      0      0      0       0       0       0       0       1
9       0      0      0      0      0       0       0       0       0       0
10      0      0      0      0      0       0       0       0       0       0
11      0      0      0      0      0       0       1       1       1       1
12      0      0      0      0      0       0       0       0       0       0
13      0      0      0      0      0       0       0       0       0       0
14      0      0      0      0      0       0       0       0       0       0
15      1      1      1      0      0       0       1       0       0       0
16      1      1      1      1      0       0       1       0       0       0
17      1      1      1      1      0       1       1       0       0       0
18      1      1      1      1      0       1       1       1       0       0
19      0      0      0      0      0       0       0       0       0       0
   SNWD.15 SNWD.16 SNWD.17 SNWD.18 SNWD.19 SNWD.20 SNWD.21 SNWD.22 SNWD.23
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       1       1       0       0       0       0       0       0       0
16       0       1       0       1       0       0       0       0       0
17       0       1       1       1       0       1       1       1       0
18       0       1       1       1       1       1       1       1       0
19       0       0       0       0       0       0       0       0       0
   SNWD.24 SNWD.25   TAVG.1   TAVG.2   TAVG.3   TAVG.4   TAVG.5   TAVG.6
1        0       0       NA       NA       NA       NA       NA       NA
2        0       0       NA       NA       NA       NA       NA       NA
3        0       0 44.00000 19.00000 14.00000 14.00000 14.00000 14.00000
4        0       0       NA       NA       NA       NA       NA       NA
5        0       0       NA       NA       NA       NA       NA       NA
6        0       0       NA       NA       NA       NA       NA       NA
7        0       0 46.12222 27.54839 29.98848 32.42857 19.00000 25.00000
8        0       0 45.00000 29.50000 20.00000 19.00000 22.50000 26.00000
9        0       0 44.36000 10.00000 18.00000 32.81818 23.94118 21.33333
10       0       0 44.00000       NA       NA       NA       NA       NA
11       0       1       NA       NA       NA       NA       NA       NA
12       0       0       NA       NA       NA       NA       NA       NA
13       0       0 47.54624 30.00000 19.80000 36.00000 36.00000 36.00000
14       0       0 49.87500 35.00000 22.00000 22.00000 22.00000 22.00000
15       0       0 39.37931 26.00000 30.70000 27.99598 24.59450 23.06667
16       0       0 28.00000 28.00000 28.00000 26.66667 24.91304 23.05556
17       0       0 40.66667 38.03448 26.56452 32.29787 23.60000 22.13580
18       0       0 40.72727 32.14286 26.00000 31.47826 23.00000 22.13333
19       0       0 14.00000 14.00000 14.00000 34.20000 27.00000 27.00000
     TAVG.7   TAVG.8   TAVG.9  TAVG.10  TAVG.11  TAVG.12  TAVG.13  TAVG.14
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
8  26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
9  21.33333 21.33333 21.33333 21.33333 21.33333 21.33333 21.33333 21.33333
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
14 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
15 21.00000 20.50000 20.00000 19.50000 19.00000 21.75000 24.50000 27.25000
16 24.14286 31.00000 28.16667 25.33333 22.50000 23.80000 25.10000 26.40000
17 26.00000 27.10526 28.45263 29.80000 25.00000 25.16621 25.33242 25.49862
18 24.00000 26.63636 28.31818 30.00000 35.00000 28.00000 27.21311 26.42623
19 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000
    TAVG.15  TAVG.16  TAVG.17  TAVG.18  TAVG.19  TAVG.20  TAVG.21  TAVG.22
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000 14.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
8  26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
9  21.33333 21.33333 21.33333 21.33333 21.33333 21.33333 21.33333 21.33333
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
14 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
15 30.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000
16 27.70000 29.00000 25.50000 22.00000 22.00000 22.00000 22.00000 22.00000
17 25.66483 25.83104 24.26531 21.75000 22.87500 24.00000 23.00000 22.00000
18 25.63934 24.85246 24.94595 22.00000 27.00000 23.07143 23.00000 22.00000
19 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000 27.00000
    TAVG.23  TAVG.24  TAVG.25   TMAX.1   TMAX.2   TMAX.3   TMAX.4   TMAX.5
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  14.00000 14.00000 14.00000 60.00000 24.00000 19.00000 19.00000 19.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  25.00000 25.00000 25.00000 53.40000 34.38710 35.87212 37.35714 32.00000
8  26.00000 26.00000 26.00000 56.50000 36.50000 25.20000 24.00000 30.00000
9  21.33333 21.33333 21.33333 59.46000 21.00000 24.00000 39.09091 35.94118
10       NA       NA       NA 60.00000       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 36.00000 36.00000 36.00000 54.32370 36.93750 24.60000 43.00000 43.00000
14 22.00000 22.00000 22.00000 58.62500 42.00000 26.50000 26.50000 26.50000
15 27.00000 27.00000 27.00000 56.72414 29.00000 34.80000 39.89135 37.63574
16 22.00000 22.00000 22.00000 33.00000 33.00000 33.00000 38.33333 37.82609
17 22.00000 22.00000 22.00000 58.26667 45.48276 31.93548 40.44681 37.40000
18 22.00000 22.00000 22.00000 58.27273 37.14286 32.50000 39.43478 37.50000
19 27.00000 27.00000 27.00000 19.00000 19.00000 19.00000 39.20000 34.00000
     TMAX.6   TMAX.7   TMAX.8   TMAX.9  TMAX.10  TMAX.11  TMAX.12  TMAX.13
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
8  36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
9  35.66667 35.66667 35.66667 35.66667 35.66667 35.66667 35.66667 35.66667
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000
14 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
15 33.86667 38.00000 37.75000 37.50000 37.25000 37.00000 37.25000 37.50000
16 34.94444 40.28571 45.00000 42.08333 39.16667 36.25000 37.20000 38.15000
17 37.23457 42.00000 42.73684 38.56842 34.40000 38.00000 38.13045 38.26090
18 36.93333 42.76923 42.79545 38.64773 34.50000 43.00000 32.00000 33.47541
19 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
    TMAX.14  TMAX.15  TMAX.16  TMAX.17  TMAX.18  TMAX.19  TMAX.20  TMAX.21
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
8  36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
9  35.66667 35.66667 35.66667 35.66667 35.66667 35.66667 35.66667 35.66667
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000 43.00000
14 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
15 37.75000 38.00000 41.00000 41.00000 41.00000 41.00000 41.00000 41.00000
16 39.10000 40.05000 41.00000 35.00000 29.00000 29.00000 29.00000 29.00000
17 38.39136 38.52181 38.65226 33.24490 28.25000 32.12500 36.00000 32.00000
18 34.95082 36.42623 37.90164 34.13514 29.00000 32.00000 35.00000 32.00000
19 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
    TMAX.22  TMAX.23  TMAX.24  TMAX.25   TMIN.1   TMIN.2   TMIN.3   TMIN.4
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  19.00000 19.00000 19.00000 19.00000 32.00000 17.00000  2.00000  2.00000
4        NA       NA       NA       NA       NA       NA       NA       NA
5        NA       NA       NA       NA       NA       NA       NA       NA
6        NA       NA       NA       NA       NA       NA       NA       NA
7  40.00000 40.00000 40.00000 40.00000 33.55556 20.41935 22.13825 23.85714
8  36.00000 36.00000 36.00000 36.00000 32.50000 23.00000 13.20000 10.00000
9  35.66667 35.66667 35.66667 35.66667 32.70000  0.00000 16.00000 22.72727
10       NA       NA       NA       NA 32.00000       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12       NA       NA       NA       NA       NA       NA       NA       NA
13 43.00000 43.00000 43.00000 43.00000 38.94798 24.56250 13.20000 25.00000
14 26.50000 26.50000 26.50000 26.50000 39.75000 31.00000 19.50000 19.50000
15 41.00000 41.00000 41.00000 41.00000 29.72414 22.00000 27.80000 21.09457
16 29.00000 29.00000 29.00000 29.00000 26.00000 26.00000 26.00000 15.00000
17 29.00000 29.00000 29.00000 29.00000 31.37778 31.62069 17.33871 27.48936
18 29.00000 29.00000 29.00000 29.00000 31.45455 26.71429 15.00000 25.00000
19 34.00000 34.00000 34.00000 34.00000  2.00000  2.00000  2.00000 25.20000
     TMIN.5   TMIN.6   TMIN.7   TMIN.8   TMIN.9  TMIN.10 TMIN.11  TMIN.12
1        NA       NA       NA       NA       NA       NA      NA       NA
2        NA       NA       NA       NA       NA       NA      NA       NA
3   2.00000  2.00000  2.00000  2.00000  2.00000  2.00000     2.0  2.00000
4        NA       NA       NA       NA       NA       NA      NA       NA
5        NA       NA       NA       NA       NA       NA      NA       NA
6        NA       NA       NA       NA       NA       NA      NA       NA
7  10.33333 12.00000 12.00000 12.00000 12.00000 12.00000    12.0 12.00000
8  11.50000 13.00000 13.00000 13.00000 13.00000 13.00000    13.0 13.00000
9  11.23529 10.00000 10.00000 10.00000 10.00000 10.00000    10.0 10.00000
10       NA       NA       NA       NA       NA       NA      NA       NA
11       NA       NA       NA       NA       NA       NA      NA       NA
12       NA       NA       NA       NA       NA       NA      NA       NA
13 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000    25.0 25.00000
14 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000    19.5 19.50000
15 13.26117 14.20000 12.00000 11.00000 10.00000  9.00000     8.0 10.00000
16 14.00000 14.27778 14.00000 22.00000 19.83333 17.66667    15.5 16.80000
17 13.80000 12.93827 15.00000 18.94737 23.37368 27.80000    18.0 17.94067
18 12.75000 13.06667 14.76923 18.54545 23.27273 28.00000    32.0 18.00000
19 17.00000 17.00000 17.00000 17.00000 17.00000 17.00000    17.0 17.00000
    TMIN.13  TMIN.14  TMIN.15  TMIN.16  TMIN.17 TMIN.18 TMIN.19  TMIN.20
1        NA       NA       NA       NA       NA      NA      NA       NA
2        NA       NA       NA       NA       NA      NA      NA       NA
3   2.00000  2.00000  2.00000  2.00000  2.00000     2.0     2.0  2.00000
4        NA       NA       NA       NA       NA      NA      NA       NA
5        NA       NA       NA       NA       NA      NA      NA       NA
6        NA       NA       NA       NA       NA      NA      NA       NA
7  12.00000 12.00000 12.00000 12.00000 12.00000    12.0    12.0 12.00000
8  13.00000 13.00000 13.00000 13.00000 13.00000    13.0    13.0 13.00000
9  10.00000 10.00000 10.00000 10.00000 10.00000    10.0    10.0 10.00000
10       NA       NA       NA       NA       NA      NA      NA       NA
11       NA       NA       NA       NA       NA      NA      NA       NA
12       NA       NA       NA       NA       NA      NA      NA       NA
13 25.00000 25.00000 25.00000 25.00000 25.00000    25.0    25.0 25.00000
14 19.50000 19.50000 19.50000 19.50000 19.50000    19.5    19.5 19.50000
15 12.00000 14.00000 16.00000 19.00000 19.00000    19.0    19.0 19.00000
16 18.10000 19.40000 20.70000 22.00000 16.50000    11.0    11.0 11.00000
17 17.88134 17.82200 17.76267 17.70334 16.69388    11.0    11.5 12.00000
18 17.61475 17.22951 16.84426 16.45902 17.72973    11.0    20.0 10.42857
19 17.00000 17.00000 17.00000 17.00000 17.00000    17.0    17.0 17.00000
   TMIN.21 TMIN.22 TMIN.23 TMIN.24 TMIN.25
1       NA      NA      NA      NA      NA
2       NA      NA      NA      NA      NA
3      2.0     2.0     2.0     2.0     2.0
4       NA      NA      NA      NA      NA
5       NA      NA      NA      NA      NA
6       NA      NA      NA      NA      NA
7     12.0    12.0    12.0    12.0    12.0
8     13.0    13.0    13.0    13.0    13.0
9     10.0    10.0    10.0    10.0    10.0
10      NA      NA      NA      NA      NA
11      NA      NA      NA      NA      NA
12      NA      NA      NA      NA      NA
13    25.0    25.0    25.0    25.0    25.0
14    19.5    19.5    19.5    19.5    19.5
15    19.0    19.0    19.0    19.0    19.0
16    11.0    11.0    11.0    11.0    11.0
17    19.0    14.0    14.0    14.0    14.0
18    19.0    14.0    14.0    14.0    14.0
19    17.0    17.0    17.0    17.0    17.0
summary(marten)
unmarkedFrame Object

19 sites
Maximum number of observations per site: 25 
Mean number of observations per site: 24.16 
Sites with at least one detection: 17 

Tabulation of y observations:
   0    1 <NA> 
 311  148   16 

Site-level covariates:
       deployment_id      sensor_height   elevation      ruggedness      
 WM01.2       : 1    Chest height: 8    Min.   :1923   Min.   :-13.0963  
 WM01.2 Ground: 1    Other       :11    1st Qu.:2191   1st Qu.: -2.1627  
 WM03.2       : 1                       Median :2311   Median : -0.8553  
 WM03.2 Ground: 1                       Mean   :2292   Mean   : -0.3879  
 WM04.2       : 1                       3rd Qu.:2402   3rd Qu.:  2.8648  
 WM04.2 Ground: 1                       Max.   :2459   Max.   :  4.0513  
 (Other)      :13                                                        

Observation-level covariates:
      PRCP             SNOW              SNWD             TAVG      
 Min.   :0.0000   Min.   :0.00000   Min.   :0.0000   Min.   :10.00  
 1st Qu.:0.0000   1st Qu.:0.00000   1st Qu.:0.0000   1st Qu.:22.00  
 Median :0.0000   Median :0.00000   Median :0.0000   Median :25.00  
 Mean   :0.1453   Mean   :0.01474   Mean   :0.1453   Mean   :25.36  
 3rd Qu.:0.0000   3rd Qu.:0.00000   3rd Qu.:0.0000   3rd Qu.:27.00  
 Max.   :1.0000   Max.   :1.00000   Max.   :1.0000   Max.   :49.88  
                                                     NA's   :199    
      TMAX            TMIN      
 Min.   :19.00   Min.   : 0.00  
 1st Qu.:29.00   1st Qu.:12.00  
 Median :35.67   Median :16.23  
 Mean   :34.82   Mean   :15.91  
 3rd Qu.:40.00   3rd Qu.:19.50  
 Max.   :60.00   Max.   :39.75  
 NA's   :199     NA's   :199    
plot(marten)

# run null model to get naive estimate of detection and occupancy
# i.e. one without covariates of either detection or occupancy
# note that the first ~1 is detection and the second ~1 is occupancy

ele_null <- occu(~1 ~1, marten)

# backtransform to get estimates

#detection
p_det <- backTransform(ele_null, "det")
p_det
Backtransformed linear combination(s) of Detection estimate(s)

 Estimate     SE LinComb (Intercept)
    0.362 0.0238  -0.567           1

Transformation: logistic 
# detection probability = 0.362 (+/- SE 0.024)

# confidence intervals for detection
detCI <- confint(p_det)
detCI
     0.025     0.975
 0.3166897 0.4095967
# CI 95% 0.317 - 0.410

# occupancy
psi <- backTransform(ele_null, "state")
psi
Backtransformed linear combination(s) of Occupancy estimate(s)

 Estimate     SE LinComb (Intercept)
    0.895 0.0704    2.14           1

Transformation: logistic 
# naive occupancy = 0.895 (+/- SE 0.070) 

psiCI <- confint(psi)
psiCI
     0.025     0.975
 0.6625918 0.9735455
# CI 95% 0.663 - 0.974

So these outputs mean that: Detection probability = 0.362 (+/- SE 0.024), CI 95% 0.317 - 0.410 Naive occupancy = 0.895 (+/- SE 0.070), CI 95% 0.663 - 0.974

Model Fitting

colSums(is.na(siteCovs(marten)))
deployment_id sensor_height     elevation    ruggedness 
            0             0             0             0 
library(unmarked)

# Detection-only models
m.null <- occu(~ 1 ~ 1, marten)

m.p.snwd <- occu(~ SNWD ~ 1, marten)
m.p.prcp <- occu(~ PRCP ~ 1, marten)

m.p.snwd.prcp <- occu(~ SNWD + PRCP ~ 1, marten)

# Occupancy-only models
m.psi.elev <- occu(~ 1 ~ elevation, marten)
m.psi.rug  <- occu(~ 1 ~ ruggedness, marten)
m.psi.sh   <- occu(~ 1 ~ sensor_height, marten)

m.psi.elev.rug <- occu(~ 1 ~ elevation + ruggedness, marten)
m.psi.full     <- occu(~ 1 ~ elevation + ruggedness + sensor_height, marten)

# Combined models
m.snwd.elev <- occu(~ SNWD ~ elevation, marten)
m.snwd.rug  <- occu(~ SNWD ~ ruggedness, marten)
m.snwd.full <- occu(~ SNWD ~ elevation + ruggedness, marten)

m.prcp.elev <- occu(~ PRCP ~ elevation, marten)
m.prcp.rug  <- occu(~ PRCP ~ ruggedness, marten)
m.prcp.full <- occu(~ PRCP ~ elevation + ruggedness, marten)

m.det.full.psi.full <- occu(~ SNWD + PRCP ~ elevation + ruggedness + sensor_height, marten)

# Model selection
fits <- fitList(
  null = m.null,
  p_snwd = m.p.snwd,
  p_prcp = m.p.prcp,
  p_snwd_prcp = m.p.snwd.prcp,
  psi_elev = m.psi.elev,
  psi_rug = m.psi.rug,
  psi_sh = m.psi.sh,
  psi_elev_rug = m.psi.elev.rug,
  psi_full = m.psi.full,
  snwd_elev = m.snwd.elev,
  snwd_rug = m.snwd.rug,
  snwd_full = m.snwd.full,
  prcp_elev = m.prcp.elev,
  prcp_rug = m.prcp.rug,
  prcp_full = m.prcp.full,
  det_full_psi_full = m.det.full.psi.full
)

modSel(fits)
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
Warning in sqrt(diag(vcov(x, altNames = TRUE))): NaNs produced
                  nPars    AIC  delta   AICwt cumltvWt
p_snwd_prcp           4 339.84   0.00 9.9e-01     0.99
det_full_psi_full     7 348.28   8.44 1.4e-02     1.00
p_prcp                3 387.37  47.54 4.7e-11     1.00
p_snwd                3 387.37  47.54 4.7e-11     1.00
snwd_rug              4 389.24  49.40 1.9e-11     1.00
prcp_rug              4 389.24  49.40 1.9e-11     1.00
prcp_elev             4 391.15  51.31 7.1e-12     1.00
snwd_elev             4 391.15  51.31 7.1e-12     1.00
prcp_full             5 392.00  52.16 4.7e-12     1.00
snwd_full             5 392.00  52.16 4.7e-12     1.00
null                  2 552.15 212.31 7.8e-47     1.00
psi_rug               3 554.01 214.17 3.1e-47     1.00
psi_sh                3 554.09 214.26 2.9e-47     1.00
psi_elev              3 555.17 215.33 1.7e-47     1.00
psi_elev_rug          4 557.25 217.41 6.1e-48     1.00
psi_full              5 559.60 219.76 1.9e-48     1.00

and export for the report:

ms_raw <- modSel(fits)@Full

model_labels <- c(
  null               = "Null model",
  p_snwd             = "Detection ~ snow depth",
  p_prcp             = "Detection ~ precipitation",
  p_snwd_prcp        = "Detection ~ snow depth + precipitation",
  psi_elev           = "Occupancy ~ elevation",
  psi_rug            = "Occupancy ~ ruggedness",
  psi_sh             = "Occupancy ~ sensor height",
  psi_elev_rug       = "Occupancy ~ elevation + ruggedness",
  psi_full           = "Occupancy ~ full model",
  snwd_elev          = "Det ~ snow depth; Occ ~ elevation",
  snwd_rug           = "Det ~ snow depth; Occ ~ ruggedness",
  snwd_full          = "Det ~ snow depth; Occ ~ full",
  prcp_elev          = "Det ~ precipitation; Occ ~ elevation",
  prcp_rug           = "Det ~ precipitation; Occ ~ ruggedness",
  prcp_full          = "Det ~ precipitation; Occ ~ full",
  det_full_psi_full  = "Detection full; Occupancy full"
)

# Build the cleaned model selection dataframe
ms_df <- ms_raw %>%
  select(model, AIC, delta, AICwt) %>%
  mutate(model = model_labels[model])   # apply readable names

# Build the GT table
gt_table <- ms_df %>%
  arrange(AIC) %>%
  gt(rowname_col = "model") %>%
  tab_stubhead(label = "Model") %>%
  tab_header(
    title = "Model Selection Table",
    subtitle = "AIC comparison of candidate occupancy models"
  ) %>%
  fmt_number(
    columns = c(AIC, delta, AICwt),
    decimals = 3
  ) %>%
  cols_label(
    AIC = "AIC",
    delta = "ΔAIC",
    AICwt = "AIC Weight"
  )

# Export the table
gtsave(
  gt_table,
  "C:/Users/coope/Documents/MSc Applied Ecology and Geospatial Techniques/Applied Pop Biol/wildlife-insights_240a773a-6a71-474a-ae0b-afed6661f231_all-platform-data/model_selection_table(marten_winter).png"
)

This tells us that snow on the ground and precipitation affects detection but not occupancy.

This supports the null hypothesis that none of the co-variates are important in telling us where the martens are found.

This is only for winter data - how does this compare to the full year of samples?

rm(list = ls())
# Detach all non-base packages
detach_all_packages <- function() {
  basic.packages <- c("package:stats", "package:graphics", "package:grDevices",
                      "package:utils", "package:datasets", "package:methods", "package:base")
  
  loaded <- search()[grepl("^package:", search())]
  to.detach <- setdiff(loaded, basic.packages)
  
  for(pkg in to.detach) {
    detach(pkg, character.only = TRUE, unload = TRUE)
  }
}

# Run it
detach_all_packages()
Warning: 'knitr' namespace cannot be unloaded:
  namespace 'knitr' is imported by 'htmlTable', 'rmarkdown' so cannot be unloaded

Occupany Model for full year Martens

Occupancy Model of the Pacfic Marten

Now this has been done, we can start to investigate and prepare for occupancy modeling. I am going to look at the Pacific marten due to a high number of sampling events and a wide range of co variate availability.

library(readr)
library(lubridate)

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(knitr)
library(kableExtra)

Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':

    group_rows
library(tidyr)
#| label: Calling the marten Data

deployments<-read.csv("deployment+covariates.csv")
marten_img<-read.csv("images+covariates.csv")%>%
  filter(genus == "Martes")

In this data, effort is constant so it is not needed as a co variate (all deployments were the same)

# ------------------------------------------------------------
# Step 1: Convert start_date and end_date to Date format
# ------------------------------------------------------------
deployments <- deployments %>%
  mutate(
    start_date = as.Date(start_date),
    end_date   = as.Date(end_date)
  )

# ------------------------------------------------------------
# Step 2: Expand deployments into daily records
# ------------------------------------------------------------
deployments_days <- deployments %>%
  rowwise() %>%
  mutate(day_seq = list(seq.Date(start_date, end_date, by = "day"))) %>%
  ungroup() %>%
  select(deployment_id, day_seq) %>%
  unnest(day_seq)

# ------------------------------------------------------------
# Step 3: Define global study period and partition length
# ------------------------------------------------------------
overall_start_date <- min(deployments$start_date)
overall_end_date   <- max(deployments$end_date)

period_length <- 5   # days per sampling occasion
total_periods <- ceiling(as.numeric(overall_end_date - overall_start_date + 1) / period_length)

# ------------------------------------------------------------
# Step 4: Create empty SO dataframe
# ------------------------------------------------------------
so_columns <- paste0("SO", 1:total_periods)

so_df <- data.frame(
  deployment_id = deployments$deployment_id,
  start_date    = deployments$start_date,
  end_date      = deployments$end_date,
  matrix(0, nrow = nrow(deployments), ncol = total_periods)
)

colnames(so_df)[4:(3 + total_periods)] <- so_columns

# ------------------------------------------------------------
# Step 5: Fill SO columns based on overlap
# ------------------------------------------------------------
for (i in seq_len(nrow(deployments))) {
  
  start_i <- deployments$start_date[i]
  end_i   <- deployments$end_date[i]
  
  for (p in seq_len(total_periods)) {
    
    period_start <- overall_start_date + days((p - 1) * period_length)
    period_end   <- period_start + days(period_length - 1)
    
    # Mark overlap
    if (period_end >= start_i && period_start <= end_i) {
      so_df[i, so_columns[p]] <- 1
    }
  }
}

# ------------------------------------------------------------
# Step 6: Sort and inspect
# ------------------------------------------------------------
so_df <- so_df %>% arrange(start_date)

head(so_df, 10)
     deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9
1    WM01.2 Ground 2020-10-08 2021-10-19   1   1   1   1   1   1   1   1   1
2           WM01.2 2020-10-08 2021-10-19   1   1   1   1   1   1   1   1   1
3           WM08.2 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
4    WM08.2 Ground 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
5           WM03.2 2020-10-09 2021-10-19   1   1   1   1   1   1   1   1   1
6    WM03.2 Ground 2020-10-09 2021-10-19   1   1   1   1   1   1   1   1   1
7  WM14 10/12/2020 2020-10-12 2021-09-25   1   1   1   1   1   1   1   1   1
8    WM12.1 Ground 2020-10-13 2021-10-12   0   1   1   1   1   1   1   1   1
9           WM12.1 2020-10-14 2021-10-12   0   1   1   1   1   1   1   1   1
10          WM04.2 2020-10-19 2021-10-30   0   0   1   1   1   1   1   1   1
   SO10 SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO25 SO26 SO27 SO28 SO29 SO30 SO31 SO32 SO33 SO34 SO35 SO36 SO37 SO38 SO39
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO40 SO41 SO42 SO43 SO44 SO45 SO46 SO47 SO48 SO49 SO50 SO51 SO52 SO53 SO54
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO55 SO56 SO57 SO58 SO59 SO60 SO61 SO62 SO63 SO64 SO65 SO66 SO67 SO68 SO69
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO70 SO71 SO72 SO73 SO74 SO75 SO76 SO77 SO78
1     1    1    1    1    1    1    1    0    0
2     1    1    1    1    1    1    1    0    0
3     1    1    1    1    1    1    1    0    0
4     1    1    1    1    1    1    1    0    0
5     1    1    1    1    1    1    1    0    0
6     1    1    1    1    1    1    1    0    0
7     1    1    0    0    0    0    0    0    0
8     1    1    1    1    1    0    0    0    0
9     1    1    1    1    1    0    0    0    0
10    1    1    1    1    1    1    1    1    1

##Build the Detection Matrix LOOK HERE FOR THE NEXT ISSUE - NAs IN THE MATRIX!!!!

# Step 1: Make sure detection timestamps are in Date format
marten_img <- marten_img %>%
  mutate(timestamp = as.Date(timestamp, format = "%Y-%m-%d"))

# Step 2: Build lookup table of SO block ranges
so_blocks <- data.frame()
for (period in 0:(ncol(so_df)-3)) {   # subtract deployment_id, start_date, end_date
  period_start <- min(so_df$start_date) + days(period * 5)
  period_end   <- period_start + days(4)
  so_blocks <- rbind(so_blocks,
                     data.frame(SO = paste0("SO", period+1),
                                block_start = period_start,
                                block_end   = period_end))
}

# Step 3: For each deployment × SO, check if detections fall in that block
detection_matrix <- so_df
for (so in so_blocks$SO) {
  block_start <- so_blocks$block_start[so_blocks$SO == so]
  block_end   <- so_blocks$block_end[so_blocks$SO == so]
  
  detection_matrix[[so]] <- mapply(function(dep_id, start_date, end_date) {
    any(marten_img$deployment_id == dep_id &
        marten_img$timestamp >= block_start &
        marten_img$timestamp <= block_end)
  }, detection_matrix$deployment_id,
     detection_matrix$start_date,
     detection_matrix$end_date)
  
  # Convert logical TRUE/FALSE to 1/0
  detection_matrix[[so]] <- as.integer(detection_matrix[[so]])
}

# Step 4: Inspect first few rows
head(detection_matrix, 10)
     deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9
1    WM01.2 Ground 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
2           WM01.2 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
3           WM08.2 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
4    WM08.2 Ground 2020-10-09 2021-10-20   0   0   0   0   1   0   0   0   0
5           WM03.2 2020-10-09 2021-10-19   0   1   1   1   1   0   1   0   0
6    WM03.2 Ground 2020-10-09 2021-10-19   0   0   0   0   0   0   0   0   0
7  WM14 10/12/2020 2020-10-12 2021-09-25   0   1   1   1   1   0   1   0   1
8    WM12.1 Ground 2020-10-13 2021-10-12   0   0   0   1   0   0   0   1   1
9           WM12.1 2020-10-14 2021-10-12   0   0   1   1   1   1   1   1   1
10          WM04.2 2020-10-19 2021-10-30   0   0   0   1   1   1   0   1   1
   SO10 SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     1    1    0    1    1    1    1    0    1    0    1    1    0    0    1
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     1    0    0    1    1    1    0    0    0    1    0    1    1    0    0
8     1    1    1    1    0    1    1    0    0    0    0    1    1    0    0
9     1    1    0    0    0    0    1    0    0    0    1    1    0    0    0
10    1    1    1    0    1    1    1    1    0    0    0    0    0    0    0
   SO25 SO26 SO27 SO28 SO29 SO30 SO31 SO32 SO33 SO34 SO35 SO36 SO37 SO38 SO39
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
2     0    0    0    0    0    1    1    1    0    0    0    0    0    0    1
3     1    0    1    0    1    1    0    1    1    1    1    1    1    1    1
4     0    0    0    0    0    0    0    0    0    0    1    0    0    0    1
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
7     0    0    0    0    1    1    0    1    1    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO40 SO41 SO42 SO43 SO44 SO45 SO46 SO47 SO48 SO49 SO50 SO51 SO52 SO53 SO54
1     1    0    0    1    0    0    0    0    0    0    0    0    0    0    0
2     1    1    0    0    0    0    0    0    0    1    0    0    0    0    0
3     1    1    1    1    1    1    1    0    0    0    0    0    0    0    0
4     1    1    1    1    1    1    1    1    1    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     1    1    1    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    1    1    1    0    0    0    0    0    1    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO55 SO56 SO57 SO58 SO59 SO60 SO61 SO62 SO63 SO64 SO65 SO66 SO67 SO68 SO69
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    1    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    1    0    1    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO70 SO71 SO72 SO73 SO74 SO75 SO76 SO77 SO78 SO79
1     0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    1    0    0    0
4     0    1    0    0    0    0    1    0    0    0
5     0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0
sum(is.na(detection_matrix))
[1] 102

This has generated some NAs in the deployments WM13, so lets remove these

# Remove the WM13 row
detection_matrix_new <- detection_matrix[!grepl("WM13", rownames(detection_matrix)), ]

# Replace all NAs with 0
detection_matrix_new[is.na(detection_matrix_new)] <- 0

ok and add the deployment covariates

Add Deployment Covariates

# Step 1: Select the covariates you want from deployments
deployment_covariates <- deployments %>%
  dplyr::select(deployment_id, sensor_height, elevation, ruggedness)

# Step 2: Join them into your detection_matrix
detection_matrix <- detection_matrix %>%
  left_join(deployment_covariates, by = "deployment_id")

# Step 3: Recode sensor_height: Other = 0, Chest Height = 1, NA treated as Chest Height (1)
detection_matrix$sensor_height_num <- ifelse(is.na(detection_matrix$sensor_height), 1,
                                      ifelse(detection_matrix$sensor_height == "Other", 0, 1))

# Step 4: Inspect the first few rows
head(detection_matrix, 10)
     deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9
1    WM01.2 Ground 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
2           WM01.2 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
3           WM08.2 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
4    WM08.2 Ground 2020-10-09 2021-10-20   0   0   0   0   1   0   0   0   0
5           WM03.2 2020-10-09 2021-10-19   0   1   1   1   1   0   1   0   0
6    WM03.2 Ground 2020-10-09 2021-10-19   0   0   0   0   0   0   0   0   0
7  WM14 10/12/2020 2020-10-12 2021-09-25   0   1   1   1   1   0   1   0   1
8    WM12.1 Ground 2020-10-13 2021-10-12   0   0   0   1   0   0   0   1   1
9           WM12.1 2020-10-14 2021-10-12   0   0   1   1   1   1   1   1   1
10          WM04.2 2020-10-19 2021-10-30   0   0   0   1   1   1   0   1   1
   SO10 SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     1    1    0    1    1    1    1    0    1    0    1    1    0    0    1
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     1    0    0    1    1    1    0    0    0    1    0    1    1    0    0
8     1    1    1    1    0    1    1    0    0    0    0    1    1    0    0
9     1    1    0    0    0    0    1    0    0    0    1    1    0    0    0
10    1    1    1    0    1    1    1    1    0    0    0    0    0    0    0
   SO25 SO26 SO27 SO28 SO29 SO30 SO31 SO32 SO33 SO34 SO35 SO36 SO37 SO38 SO39
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
2     0    0    0    0    0    1    1    1    0    0    0    0    0    0    1
3     1    0    1    0    1    1    0    1    1    1    1    1    1    1    1
4     0    0    0    0    0    0    0    0    0    0    1    0    0    0    1
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
7     0    0    0    0    1    1    0    1    1    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO40 SO41 SO42 SO43 SO44 SO45 SO46 SO47 SO48 SO49 SO50 SO51 SO52 SO53 SO54
1     1    0    0    1    0    0    0    0    0    0    0    0    0    0    0
2     1    1    0    0    0    0    0    0    0    1    0    0    0    0    0
3     1    1    1    1    1    1    1    0    0    0    0    0    0    0    0
4     1    1    1    1    1    1    1    1    1    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     1    1    1    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    1    1    1    0    0    0    0    0    1    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO55 SO56 SO57 SO58 SO59 SO60 SO61 SO62 SO63 SO64 SO65 SO66 SO67 SO68 SO69
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    1    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    1    0    1    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO70 SO71 SO72 SO73 SO74 SO75 SO76 SO77 SO78 SO79 sensor_height elevation
1     0    0    0    0    0    0    0    0    0    0  Chest height      2311
2     0    0    0    0    0    0    0    0    0    0         Other      2311
3     0    0    0    0    0    0    1    0    0    0         Other      2459
4     0    1    0    0    0    0    1    0    0    0         Other      2459
5     0    0    0    0    0    0    0    0    0    0         Other      2402
6     0    0    0    0    0    0    0    0    0    0  Chest height      2402
7     0    0    0    0    0    0    0    0    0    0         Other      1923
8     0    0    0    0    0    0    0    0    0    0  Chest height      2375
9     0    0    0    0    0    0    0    0    0    0         Other      2375
10    0    0    0    0    0    0    0    0    0    0         Other      2209
   ruggedness sensor_height_num
1   -2.082459                 1
2   -2.082459                 0
3    3.099113                 0
4    3.099113                 0
5    2.864809                 0
6    2.864809                 1
7  -13.096323                 0
8    1.759304                 1
9    1.759304                 0
10  -2.627357                 0

adding sample specific covariats and changing data for model

Add Sample Covariates

There were a lot of NAs in the weather data, to help with this snowdepth is going to be changed to a presence/absence binary variable.

# Step 1: Pivot detection_matrix into long format (deployment × SO occasion)
detection_long <- detection_matrix %>%
  pivot_longer(
    cols = starts_with("SO"),
    names_to = "SO",
    values_to = "detection"
  )

# Step 2: Assign each timestamp to an SO block
marten_img <- marten_img %>%
  mutate(
    SO = paste0(
      "SO",
      floor(as.numeric(difftime(timestamp, min(detection_matrix$start_date), units = "days")) / 5) + 1
    )
  )

# Step 3: Aggregate covariates by deployment × SO (mean values per block)
sample_covariates <- marten_img %>%
  group_by(deployment_id, SO) %>%
  summarise(
    PRCP = mean(PRCP, na.rm = TRUE),
    SNOW = mean(SNOW, na.rm = TRUE),
    SNWD = mean(SNWD, na.rm = TRUE),
    TAVG = mean(TAVG, na.rm = TRUE),
    TMAX = mean(TMAX, na.rm = TRUE),
    TMIN = mean(TMIN, na.rm = TRUE),
    .groups = "drop"
  )

# Step 4: Join sample-level covariates into detection_long
detection_long <- detection_long %>%
  left_join(sample_covariates, by = c("deployment_id", "SO"))

# convert SNWD to binary presence/absence (treat NA as 0 = no snow)
detection_long$SNWD <- ifelse(is.na(detection_long$SNWD), 0,
                              ifelse(detection_long$SNWD > 0, 1, 0))

# Step 5: Inspect
head(detection_long, 10)
# A tibble: 10 × 15
   deployment_id start_date end_date   sensor_height elevation ruggedness
   <chr>         <date>     <date>     <chr>             <int>      <dbl>
 1 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 2 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 3 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 4 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 5 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 6 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 7 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 8 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
 9 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
10 WM01.2 Ground 2020-10-08 2021-10-19 Chest height       2311      -2.08
# ℹ 9 more variables: sensor_height_num <dbl>, SO <chr>, detection <int>,
#   PRCP <dbl>, SNOW <dbl>, SNWD <dbl>, TAVG <dbl>, TMAX <dbl>, TMIN <dbl>

This gives us the fully integrated data set! Yay!

# Extract detection history (matrix of 1/0)
y <- detection_matrix %>%
  select(starts_with("SO")) %>%
  as.matrix()
# Use the same overall_start_date and total_periods you defined earlier
overall_start_date <- min(detection_matrix$start_date)
period_length <- 5
total_periods <- ncol(y)   # should be 25
print(ncol(y))
[1] 79
# Assign SO blocks consistently
marten_img <- marten_img %>%
  mutate(SO = paste0(
    "SO",
    floor(as.numeric(difftime(timestamp, overall_start_date, units = "days")) / period_length) + 1
  ))

# Summarise covariates per deployment × SO
obs_covs_long <- marten_img %>%
  group_by(deployment_id, SO) %>%
  summarise(
    PRCP = mean(PRCP, na.rm = TRUE),
    SNOW = mean(SNOW, na.rm = TRUE),
    SNWD = mean(SNWD, na.rm = TRUE),
    TAVG = mean(TAVG, na.rm = TRUE),
    TMAX = mean(TMAX, na.rm = TRUE),
    TMIN = mean(TMIN, na.rm = TRUE),
    .groups = "drop"
  )

# Build complete grid of deployment × SO
so_cols <- colnames(y)
dep_order <- detection_matrix$deployment_id
complete_grid <- expand.grid(
  deployment_id = dep_order,
  SO = so_cols,
  stringsAsFactors = FALSE
)

obs_covs_complete <- complete_grid %>%
  left_join(obs_covs_long, by = c("deployment_id", "SO"))

# Convert SNWD to binary presence/absence (treat NA as 0)
obs_covs_complete$SNWD <- ifelse(
  is.na(obs_covs_complete$SNWD), 0,
  ifelse(obs_covs_complete$SNWD > 0, 1, 0)
)

# Convert PRCP to binary presence/absence (treat NA as 0)
obs_covs_complete$PRCP <- ifelse(
  is.na(obs_covs_complete$PRCP), 0,
  ifelse(obs_covs_complete$PRCP > 0, 1, 0)
)

# Convert SNOW to binary presence/absence (treat NA as 0)
obs_covs_complete$SNOW <- ifelse(
  is.na(obs_covs_complete$SNOW), 0,
  ifelse(obs_covs_complete$SNOW > 0, 1, 0)
)

# Interpolate TAVG, TMAX, TMIN within each deployment
obs_covs_complete <- obs_covs_complete %>%
  group_by(deployment_id) %>%
  mutate(
    TAVG = zoo::na.approx(TAVG, na.rm = FALSE, rule = 2),
    TMAX = zoo::na.approx(TMAX, na.rm = FALSE, rule = 2),
    TMIN = zoo::na.approx(TMIN, na.rm = FALSE, rule = 2)
  ) %>%
  ungroup()

# Pivot each covariate into a 19 × 25 matrix
make_obs_matrix <- function(df, value_col) {
  wide <- df %>%
    select(deployment_id, SO, !!sym(value_col)) %>%
    pivot_wider(names_from = SO, values_from = !!sym(value_col))
  wide <- wide %>% slice(match(dep_order, deployment_id))
  as.matrix(wide[, so_cols])
}

obs_covs_list <- list(
  PRCP = make_obs_matrix(obs_covs_complete, "PRCP"),
  SNOW = make_obs_matrix(obs_covs_complete, "SNOW"),
  SNWD = make_obs_matrix(obs_covs_complete, "SNWD"),
  TAVG = make_obs_matrix(obs_covs_complete, "TAVG"),
  TMAX = make_obs_matrix(obs_covs_complete, "TMAX"),
  TMIN = make_obs_matrix(obs_covs_complete, "TMIN")
)

dim(y)
[1] 19 79
lapply(obs_covs_list, dim)
$PRCP
[1] 19 79

$SNOW
[1] 19 79

$SNWD
[1] 19 79

$TAVG
[1] 19 79

$TMAX
[1] 19 79

$TMIN
[1] 19 79

Within this chunk I have interpolated the missing temperature data and changed SNOW and PRCP to binary values. This is to help the model running and to increase he biological validity of our results.

Correlation between site covariates

site_covs <- deployment_covariates[, c("elevation", "ruggedness", "sensor_height")]

# Recode sensor_height: Other = 0, Chest Height = 1, NA treated as Chest Height (1)
site_covs$sensor_height <- ifelse(is.na(site_covs$sensor_height), 1,
                           ifelse(site_covs$sensor_height == "Other", 0, 1))

# Now everything is numeric
cor(site_covs, use = "pairwise.complete.obs")
               elevation ruggedness sensor_height
elevation     1.00000000  0.9294703    0.01398884
ruggedness    0.92947029  1.0000000    0.07965490
sensor_height 0.01398884  0.0796549    1.00000000

This is telling us that the elevation and ruggedness are highly correlated 92.9%, with sensor height not correlated with either.

library(Hmisc)

Attaching package: 'Hmisc'
The following objects are masked from 'package:dplyr':

    src, summarize
The following objects are masked from 'package:base':

    format.pval, units
covs <- obs_covs_complete %>%
  select(PRCP, SNOW, SNWD, TAVG, TMAX, TMIN)

res <- rcorr(as.matrix(covs), type = "pearson")

res$r
           PRCP      SNOW        SNWD       TAVG        TMAX       TMIN
PRCP  1.0000000 0.2508403  0.62961280 -0.1235066 -0.13170508 -0.1055726
SNOW  0.2508403 1.0000000  0.11663787         NA          NA         NA
SNWD  0.6296128 0.1166379  1.00000000 -0.1247655 -0.09835712 -0.1311682
TAVG -0.1235066        NA -0.12476549  1.0000000  0.97185636  0.9412014
TMAX -0.1317051        NA -0.09835712  0.9718564  1.00000000  0.8592234
TMIN -0.1055726        NA -0.13116818  0.9412014  0.85922336  1.0000000
res$P
             PRCP         SNOW         SNWD         TAVG         TMAX
PRCP           NA 0.000000e+00 0.000000e+00 0.0001376752 4.751442e-05
SNOW 0.000000e+00           NA 5.882267e-06           NA           NA
SNWD 0.000000e+00 5.882267e-06           NA 0.0001174106 2.431522e-03
TAVG 1.376752e-04           NA 1.174106e-04           NA 0.000000e+00
TMAX 4.751442e-05           NA 2.431522e-03 0.0000000000           NA
TMIN 1.132520e-03           NA 5.104242e-05 0.0000000000 0.000000e+00
             TMIN
PRCP 1.132520e-03
SNOW           NA
SNWD 5.104242e-05
TAVG 0.000000e+00
TMAX 0.000000e+00
TMIN           NA
res$n
     PRCP SNOW SNWD TAVG TMAX TMIN
PRCP 1501 1501 1501  948  948  948
SNOW 1501 1501 1501  948  948  948
SNWD 1501 1501 1501  948  948  948
TAVG  948  948  948  948  948  948
TMAX  948  948  948  948  948  948
TMIN  948  948  948  948  948  948
print(res$r)
           PRCP      SNOW        SNWD       TAVG        TMAX       TMIN
PRCP  1.0000000 0.2508403  0.62961280 -0.1235066 -0.13170508 -0.1055726
SNOW  0.2508403 1.0000000  0.11663787         NA          NA         NA
SNWD  0.6296128 0.1166379  1.00000000 -0.1247655 -0.09835712 -0.1311682
TAVG -0.1235066        NA -0.12476549  1.0000000  0.97185636  0.9412014
TMAX -0.1317051        NA -0.09835712  0.9718564  1.00000000  0.8592234
TMIN -0.1055726        NA -0.13116818  0.9412014  0.85922336  1.0000000

So this is telling us that: - only one temperature variable should be used for modelling - precipitation and snow depth should not be combined

Unmarked object creation

library(unmarked)

marten <- unmarkedFrameOccu(
  y = y,
  siteCovs = deployment_covariates,
  obsCovs = obs_covs_list
)
Warning: siteCovs contains characters. Converting them to factors.
# Inspect
marten
Data frame representation of unmarkedFrame object.
   y.1 y.2 y.3 y.4 y.5 y.6 y.7 y.8 y.9 y.10 y.11 y.12 y.13 y.14 y.15 y.16 y.17
1    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
2    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
3    1   1   1   1   1   1   1   1   1    1    1    0    1    1    1    1    0
4    0   0   0   0   1   0   0   0   0    0    0    0    0    0    0    0    0
5    0   1   1   1   1   0   1   0   0    0    0    0    0    0    0    0    0
6    0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
7    0   1   1   1   1   0   1   0   1    1    0    0    1    1    1    0    0
8    0   0   0   1   0   0   0   1   1    1    1    1    1    0    1    1    0
9    0   0   1   1   1   1   1   1   1    1    1    0    0    0    0    1    0
10   0   0   0   1   1   1   0   1   1    1    1    1    0    1    1    1    1
11   0   0   0   0   0   0   0   0   1    1    1    1    0    0    0    1    0
12  NA  NA  NA   1   1   1   1   1   1    1    1    1    1   NA    1    1   NA
13  NA  NA  NA  NA   1   1   1   1   1    1    1    1    1   NA    1    1   NA
14   0   0   0   0   0   0   0   0   0    0    0    0    0    0    0    0    0
15   0   0   0   0   0   0   0   1   1    1    1    1    0    1    0    1    0
16   0   0   0   0   1   1   1   1   0    0    0    0    0    0    0    0    0
17   0   0   0   0   1   1   0   1   0    0    0    0    0    0    0    0    0
18   0   0   0   0   1   1   1   1   1    0    1    0    0    0    0    0    1
19   0   0   0   0   1   1   1   1   1    1    1    0    1    1    0    0    1
   y.18 y.19 y.20 y.21 y.22 y.23 y.24 y.25 y.26 y.27 y.28 y.29 y.30 y.31 y.32
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    1    1    1
3     1    0    1    1    0    0    1    1    0    1    0    1    1    0    1
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    1    0    1    1    0    0    0    0    0    0    1    1    0    1
8     0    0    0    1    1    0    0    0    0    0    0    0    0    0    0
9     0    0    1    1    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
11    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
12   NA   NA    1    1    1    1    1    1    1   NA   NA   NA   NA   NA    1
13   NA   NA    1    1    1    1   NA    1    1   NA   NA   NA   NA   NA   NA
14    0    0    0    1    0    0    0    0    0    0    0    0    0    0    0
15    1    1    0    0    0    1    0    0    0    0    0    0    1    0    0
16    0    0    0    1    1    1    0    0    0    0    0    0    0    0    0
17    0    0    1    1    1    1    0    0    0    0    0    0    0    0    0
18    1    1    1    1    0    0    0    1    0    0    0    0    0    0    0
19    0    0    1    0    0    0    0    0    0    0    0    0    0    0    0
   y.33 y.34 y.35 y.36 y.37 y.38 y.39 y.40 y.41 y.42 y.43 y.44 y.45 y.46 y.47
1     0    0    0    0    0    0    1    1    0    0    1    0    0    0    0
2     0    0    0    0    0    0    1    1    1    0    0    0    0    0    0
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    0
4     0    0    1    0    0    0    1    1    1    1    1    1    1    1    1
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    1    1    1    1    0    0    0    0    0
7     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    1    1    1    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    1    0    0    0    0    0    0    0
11    0    0    0    0    0    0    0    0    0    1    0    0    1    0    0
12    1    1    1    1    1    1    1    1    1    1    1   NA    1   NA    1
13    1    1    1    1    1    1   NA   NA   NA   NA   NA   NA   NA   NA   NA
14    0    0    0    0    0    0    0    0    0    0    0    1    0    1    1
15    0    0    1    0    0    1    0    0    1    0    0    0    0    0    0
16    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
17    0    0    1    1    0    1    0    0    0    0    0    0    0    0    0
18    0    0    0    1    1    1    0    0    0    0    0    0    0    0    1
19    0    0    1    1    1    1    1    1    0    1    1    0    0    0    0
   y.48 y.49 y.50 y.51 y.52 y.53 y.54 y.55 y.56 y.57 y.58 y.59 y.60 y.61 y.62
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    1    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    1    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
11    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
12   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
13   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
14    1    0    0    0    1    0    0    0    0    0    0    0    0    0    0
15    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
16    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
17    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
18    1    0    0    1    0    0    0    0    1    0    0    0    0    0    0
19    0    0    1    0    0    0    0    0    0    0    0    0    0    0    0
   y.63 y.64 y.65 y.66 y.67 y.68 y.69 y.70 y.71 y.72 y.73 y.74 y.75 y.76 y.77
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    1    0
4     0    0    0    0    0    0    0    0    1    0    0    0    0    1    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    1    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    1    0    1    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
11    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
12   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
13   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
14    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
15    0    0    0    0    0    0    1    0    0    0    0    0    0    0    0
16    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
17    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
18    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
19    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   y.78 y.79          deployment_id sensor_height elevation  ruggedness PRCP.1
1     0    0                 WM08.2         Other      2459   3.0991125      0
2     0    0          WM01.2 Ground  Chest height      2311  -2.0824588      0
3     0    0                 WM12.1         Other      2375   1.7593043      1
4     0    0          WM08.2 Ground         Other      2459   3.0991125      0
5     0    0          WM13.1 Ground  Chest height      2255  -1.1037417      0
6     0    0 WM09 Ground 10/29/2020  Chest height      2173  -0.8553052      0
7     0    0        WM09 10/29/2020         Other      2173  -0.8553052      0
8     0    0                 WM04.2         Other      2209  -2.6273567      0
9     0    0                   WM13         Other      2255  -1.1037417      0
10    0    0          WM12.1 Ground  Chest height      2375   1.7593043      0
11    0    0                 WM10.2         Other      2173  -2.2429066      0
12   NA   NA          WM10.2 Ground  Chest height      2173  -2.2429066      0
13   NA   NA                 WM01.2         Other      2311  -2.0824588      0
14    0    0                 WM03.2         Other      2402   2.8648094      0
15    0    0          WM03.2 Ground  Chest height      2402   2.8648094      0
16    0    0          WM04.2 Ground  Chest height      2209  -2.6273567      0
17    0    0          WM06.2 Ground  Chest height      2459   4.0513298      0
18    0    0                 WM06.2         Other      2459   4.0513298      0
19    0    0        WM14 10/12/2020         Other      1923 -13.0963227      0
   PRCP.2 PRCP.3 PRCP.4 PRCP.5 PRCP.6 PRCP.7 PRCP.8 PRCP.9 PRCP.10 PRCP.11
1       0      0      0      0      0      0      0      0       0       0
2       0      0      0      0      0      0      0      0       0       0
3       1      1      1      0      0      1      1      1       1       0
4       0      0      0      0      0      0      0      0       0       0
5       1      0      1      0      0      1      0      0       0       0
6       0      0      0      0      0      0      0      0       0       0
7       1      1      1      0      0      1      0      1       1       0
8       0      0      1      0      0      0      1      0       1       1
9       0      0      1      0      0      1      1      1       1       1
10      0      0      0      0      0      0      0      0       1       0
11      0      0      0      0      0      0      0      0       1       0
12      0      0      0      0      0      1      1      1       0       1
13      0      0      0      0      0      1      1      1       0       0
14      0      0      0      0      0      0      0      0       0       0
15      0      0      0      0      0      0      0      1       1       1
16      0      0      0      0      1      1      1      0       0       0
17      0      0      0      0      1      0      1      0       0       0
18      0      0      0      0      1      1      1      1       0       0
19      0      0      0      0      1      1      1      1       1       0
   PRCP.12 PRCP.13 PRCP.14 PRCP.15 PRCP.16 PRCP.17 PRCP.18 PRCP.19 PRCP.20
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        1       0       0       1       1       0       0       0       0
9        0       0       0       0       0       0       0       0       1
10       0       0       1       1       1       1       0       0       0
11       0       0       0       0       0       0       0       0       0
12       1       0       0       1       1       0       0       0       0
13       1       0       0       1       1       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       1       0       1       1       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.21 PRCP.22 PRCP.23 PRCP.24 PRCP.25 PRCP.26 PRCP.27 PRCP.28 PRCP.29
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       1       0       0       0       0       0       0       0
9        1       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       1       1       0       0       0       1       0       0       0
13       1       1       1       0       0       1       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.30 PRCP.31 PRCP.32 PRCP.33 PRCP.34 PRCP.35 PRCP.36 PRCP.37 PRCP.38
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       1       1       1       0       0       0
13       0       0       0       1       1       1       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.39 PRCP.40 PRCP.41 PRCP.42 PRCP.43 PRCP.44 PRCP.45 PRCP.46 PRCP.47
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       1       1       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       1       1
15       0       0       1       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.48 PRCP.49 PRCP.50 PRCP.51 PRCP.52 PRCP.53 PRCP.54 PRCP.55 PRCP.56
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.57 PRCP.58 PRCP.59 PRCP.60 PRCP.61 PRCP.62 PRCP.63 PRCP.64 PRCP.65
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.66 PRCP.67 PRCP.68 PRCP.69 PRCP.70 PRCP.71 PRCP.72 PRCP.73 PRCP.74
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   PRCP.75 PRCP.76 PRCP.77 PRCP.78 PRCP.79 SNOW.1 SNOW.2 SNOW.3 SNOW.4 SNOW.5
1        0       0       0       0       0      0      0      0      0      0
2        0       0       0       0       0      0      0      0      0      0
3        0       0       0       0       0      0      0      0      0      0
4        0       0       0       0       0      0      0      0      0      0
5        0       0       0       0       0      0      0      0      0      0
6        0       0       0       0       0      0      0      0      0      0
7        0       0       0       0       0      0      0      0      0      0
8        0       0       0       0       0      0      0      0      0      0
9        0       0       0       0       0      0      0      0      0      0
10       0       0       0       0       0      0      0      0      0      0
11       0       0       0       0       0      0      0      0      0      0
12       0       0       0       0       0      0      0      0      0      0
13       0       0       0       0       0      0      0      0      0      0
14       0       0       0       0       0      0      0      0      0      0
15       0       0       0       0       0      0      0      0      0      0
16       0       0       0       0       0      0      0      0      0      0
17       0       0       0       0       0      0      0      0      0      0
18       0       0       0       0       0      0      0      0      0      0
19       0       0       0       0       0      0      0      0      0      0
   SNOW.6 SNOW.7 SNOW.8 SNOW.9 SNOW.10 SNOW.11 SNOW.12 SNOW.13 SNOW.14 SNOW.15
1       0      0      0      0       0       0       0       0       0       0
2       0      0      0      0       0       0       0       0       0       0
3       0      0      0      0       0       0       0       0       0       0
4       0      0      0      0       0       0       0       0       0       0
5       0      0      0      0       0       0       0       0       0       0
6       0      0      0      0       0       0       0       0       0       0
7       0      0      0      0       0       0       0       0       0       0
8       0      0      0      0       0       0       0       0       0       0
9       0      0      0      0       0       0       0       0       0       0
10      0      0      0      0       1       0       0       0       0       0
11      0      0      0      0       1       0       0       0       0       0
12      0      0      0      0       0       0       0       0       0       0
13      0      0      0      0       0       0       0       0       0       0
14      0      0      0      0       0       0       0       0       0       0
15      0      0      0      0       1       0       0       0       0       0
16      0      0      0      0       0       0       0       0       0       0
17      0      0      0      0       0       0       0       0       0       0
18      0      0      0      0       0       0       0       0       0       0
19      0      0      0      0       0       0       0       0       0       0
   SNOW.16 SNOW.17 SNOW.18 SNOW.19 SNOW.20 SNOW.21 SNOW.22 SNOW.23 SNOW.24
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       1       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       1       0       0       1       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.25 SNOW.26 SNOW.27 SNOW.28 SNOW.29 SNOW.30 SNOW.31 SNOW.32 SNOW.33
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.34 SNOW.35 SNOW.36 SNOW.37 SNOW.38 SNOW.39 SNOW.40 SNOW.41 SNOW.42
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.43 SNOW.44 SNOW.45 SNOW.46 SNOW.47 SNOW.48 SNOW.49 SNOW.50 SNOW.51
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.52 SNOW.53 SNOW.54 SNOW.55 SNOW.56 SNOW.57 SNOW.58 SNOW.59 SNOW.60
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.61 SNOW.62 SNOW.63 SNOW.64 SNOW.65 SNOW.66 SNOW.67 SNOW.68 SNOW.69
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.70 SNOW.71 SNOW.72 SNOW.73 SNOW.74 SNOW.75 SNOW.76 SNOW.77 SNOW.78
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNOW.79 SNWD.1 SNWD.2 SNWD.3 SNWD.4 SNWD.5 SNWD.6 SNWD.7 SNWD.8 SNWD.9
1        0      0      0      0      0      0      0      0      0      0
2        0      0      0      0      0      0      0      0      0      0
3        0      0      0      0      1      0      0      1      1      0
4        0      0      0      0      0      0      0      0      0      0
5        0      0      0      0      1      0      0      1      0      0
6        0      0      0      0      0      0      0      0      0      0
7        0      0      0      0      1      0      0      1      0      0
8        0      0      0      0      0      0      0      0      1      1
9        0      0      0      0      0      0      0      1      1      1
10       0      0      0      0      0      0      0      0      0      0
11       0      0      0      0      0      0      0      0      0      0
12       0      0      0      0      0      0      0      1      1      1
13       0      0      0      0      0      0      0      1      1      1
14       0      0      0      0      0      0      0      0      0      0
15       0      0      0      0      0      0      0      0      1      0
16       0      0      0      0      0      0      0      1      1      0
17       0      0      0      0      0      0      0      0      1      0
18       0      0      0      0      0      0      0      1      1      0
19       0      0      0      0      0      0      0      1      0      0
   SNWD.10 SNWD.11 SNWD.12 SNWD.13 SNWD.14 SNWD.15 SNWD.16 SNWD.17 SNWD.18
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        1       1       1       1       0       1       1       0       0
9        1       1       0       0       0       0       1       0       0
10       0       0       0       0       0       0       1       0       0
11       0       0       0       0       0       0       0       0       0
12       1       1       1       1       0       1       1       0       0
13       1       1       1       1       0       1       1       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       1       0       1
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.19 SNWD.20 SNWD.21 SNWD.22 SNWD.23 SNWD.24 SNWD.25 SNWD.26 SNWD.27
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       1       1       0       0       0       0       0
9        0       1       1       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       1       1       1       1       1       1       1       0
13       0       1       1       1       1       0       1       1       0
14       0       0       0       0       0       0       0       0       0
15       1       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       1       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.28 SNWD.29 SNWD.30 SNWD.31 SNWD.32 SNWD.33 SNWD.34 SNWD.35 SNWD.36
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       1       1       1       1       1
13       0       0       0       0       0       1       1       1       1
14       0       0       0       0       0       0       0       0       0
15       0       0       1       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.37 SNWD.38 SNWD.39 SNWD.40 SNWD.41 SNWD.42 SNWD.43 SNWD.44 SNWD.45
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       1       1       1       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       1       1       1       1       1       1       1       0       1
13       1       1       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.46 SNWD.47 SNWD.48 SNWD.49 SNWD.50 SNWD.51 SNWD.52 SNWD.53 SNWD.54
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.55 SNWD.56 SNWD.57 SNWD.58 SNWD.59 SNWD.60 SNWD.61 SNWD.62 SNWD.63
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.64 SNWD.65 SNWD.66 SNWD.67 SNWD.68 SNWD.69 SNWD.70 SNWD.71 SNWD.72
1        0       0       0       0       0       0       0       0       0
2        0       0       0       0       0       0       0       0       0
3        0       0       0       0       0       0       0       0       0
4        0       0       0       0       0       0       0       0       0
5        0       0       0       0       0       0       0       0       0
6        0       0       0       0       0       0       0       0       0
7        0       0       0       0       0       0       0       0       0
8        0       0       0       0       0       0       0       0       0
9        0       0       0       0       0       0       0       0       0
10       0       0       0       0       0       0       0       0       0
11       0       0       0       0       0       0       0       0       0
12       0       0       0       0       0       0       0       0       0
13       0       0       0       0       0       0       0       0       0
14       0       0       0       0       0       0       0       0       0
15       0       0       0       0       0       0       0       0       0
16       0       0       0       0       0       0       0       0       0
17       0       0       0       0       0       0       0       0       0
18       0       0       0       0       0       0       0       0       0
19       0       0       0       0       0       0       0       0       0
   SNWD.73 SNWD.74 SNWD.75 SNWD.76 SNWD.77 SNWD.78 SNWD.79   TAVG.1   TAVG.2
1        0       0       0       0       0       0       0       NA       NA
2        0       0       0       0       0       0       0       NA       NA
3        0       0       0       0       0       0       0 36.00000 36.06949
4        0       0       0       0       0       0       0 44.00000 44.00000
5        0       0       0       0       0       0       0 34.61111 34.61111
6        0       0       0       0       0       0       0       NA       NA
7        0       0       0       0       0       0       0 30.51810 30.51810
8        0       0       0       0       0       0       0 22.50000 22.50000
9        0       0       0       0       0       0       0 45.00000 45.00000
10       0       0       0       0       0       0       0       NA       NA
11       0       0       0       0       0       0       0       NA       NA
12       0       0       0       0       0       0       0 33.00000 33.00000
13       0       0       0       0       0       0       0 38.00000 38.00000
14       0       0       0       0       0       0       0       NA       NA
15       0       0       0       0       0       0       0       NA       NA
16       0       0       0       0       0       0       0 44.00000 44.00000
17       0       0       0       0       0       0       0 30.00000 30.00000
18       0       0       0       0       0       0       0 44.00000 44.00000
19       0       0       0       0       0       0       0 36.00000 36.00000
     TAVG.3   TAVG.4   TAVG.5   TAVG.6   TAVG.7   TAVG.8   TAVG.9  TAVG.10
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  35.29808 23.03704 37.28448 47.60000 10.00000 34.00000 22.00000 23.88235
4  44.00000 44.00000 44.00000 44.06061 44.12121 44.18182 44.24242 44.30303
5  18.00000 19.00000 38.00000 27.92308 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  38.96296 17.84615 41.87879 27.93939 14.00000 24.10000 34.20000 27.00000
8  22.50000 22.50000 23.87500 25.25000 26.62500 28.00000 26.66667 24.76000
9  45.00000 25.75622 37.82152 42.00000 26.00000 32.68000 26.92891 24.51634
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 33.00000 33.00000 38.27160 41.80000 27.50000 28.00000 30.56000 23.60000
13 38.00000 38.00000 38.00000 41.84906 26.84314 29.05634 31.53968 23.83333
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 44.00000 44.00000 44.00000 45.84848 18.16667 26.16667 26.16667 26.16667
17 30.00000 30.00000 30.00000 48.22222 35.11111 22.00000 22.00000 22.00000
18 44.00000 44.00000 44.00000 40.50000 24.00000 20.00000 19.00000 22.50000
19 36.00000 36.00000 36.00000 42.43511 23.45000 36.00000 29.42857 27.00000
    TAVG.11  TAVG.12  TAVG.13  TAVG.14  TAVG.15  TAVG.16  TAVG.17  TAVG.18
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  25.00000 25.21538 25.43077 25.64615 25.86154 26.07692 26.29231 26.50769
4  44.36364 44.42424 44.48485 44.54545 44.60606 44.66667 44.72727 44.78788
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  27.31034 27.62069 27.93103 28.24138 28.55172 28.86207 29.17241 29.48276
8  22.83333 25.40000 31.00000 33.00000 35.00000 18.33333 20.46667 22.60000
9  22.92308 22.13846 21.35385 20.56923 19.78462 19.00000 21.75000 24.50000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 21.92857 24.25000 26.63636 28.81818 31.00000 28.00000 27.50000 27.00000
13 21.92308 26.00000 27.10526 28.45263 29.80000 25.00000 25.25000 25.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.19  TAVG.20  TAVG.21  TAVG.22  TAVG.23  TAVG.24  TAVG.25  TAVG.26
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  26.72308 26.93846 27.15385 27.36923 27.58462 27.80000 28.01538 28.23077
4  44.84848 44.90909 44.96970 45.03030 45.09091 45.15152 45.21212 45.27273
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  29.79310 30.10345 30.41379 30.72414 31.03448 31.34483 31.65517 31.96552
8  24.73333 26.86667 29.00000 22.00000 23.05000 24.10000 25.15000 26.20000
9  27.25000 30.00000 27.00000 27.51163 28.02326 28.53488 29.04651 29.55814
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 26.50000 26.00000 24.53448 25.15152 27.00000 23.00000 23.07692 22.50000
13 25.75000 26.00000 25.52371 24.17021 20.00000 22.00000 24.00000 22.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.27  TAVG.28  TAVG.29  TAVG.30  TAVG.31  TAVG.32  TAVG.33  TAVG.34
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  28.44615 28.66154 28.87692 29.09231 29.30769 29.52308 29.73846 29.95385
4  45.33333 45.39394 45.45455 45.51515 45.57576 45.63636 45.69697 45.75758
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  32.27586 32.58621 32.89655 33.20690 33.51724 33.82759 34.13793 34.44828
8  27.25000 28.30000 29.35000 30.40000 31.45000 32.50000 33.55000 34.60000
9  30.06977 30.58140 31.09302 31.60465 32.11628 32.62791 33.13953 33.65116
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 24.75000 27.00000 29.25000 31.50000 33.75000 36.00000 31.28205 29.02326
13 23.76000 25.02000 26.28000 27.54000 28.80000 30.06000 31.32000 29.13115
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.35  TAVG.36  TAVG.37  TAVG.38  TAVG.39  TAVG.40  TAVG.41  TAVG.42
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  30.16923 30.38462 30.60000 30.81538 31.03077 31.24615 31.46154 31.67692
4  45.81818 45.87879 45.93939 46.00000 46.06061 46.12121 46.18182 46.24242
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  34.75862 35.06897 35.37931 35.68966 36.00000 36.31034 36.62069 36.93103
8  35.65000 36.70000 37.75000 38.80000 39.85000 40.90000 41.95000 43.00000
9  34.16279 34.67442 35.18605 35.69767 36.20930 36.72093 37.23256 37.74419
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 33.51096 40.15789 34.00000 35.28571 38.00000 38.53883 43.94881 41.60825
13 33.32353 40.33333 31.00000 35.50000 35.50000 35.50000 35.50000 35.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.43  TAVG.44  TAVG.45  TAVG.46  TAVG.47  TAVG.48  TAVG.49  TAVG.50
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  31.89231 32.10769 32.32308 32.53846 32.75385 32.96923 33.18462 33.40000
4  46.30303 46.36364 46.42424 46.48485 46.54545 46.60606 46.66667 46.72727
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  37.24138 37.55172 37.86207 38.17241 38.48276 38.79310 39.10345 39.41379
8  38.00000 46.00000 48.83333 51.66667 54.50000 57.33333 60.16667 63.00000
9  38.25581 38.76744 39.27907 39.79070 40.30233 40.81395 41.32558 41.83721
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 40.60000 46.30000 52.00000 48.00000 44.00000 44.00000 44.00000 44.00000
13 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.51  TAVG.52  TAVG.53  TAVG.54  TAVG.55  TAVG.56  TAVG.57  TAVG.58
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  33.61538 33.83077 34.04615 34.26154 34.47692 34.69231 34.90769 35.12308
4  46.78788 46.84848 46.90909 46.96970 47.03030 47.09091 47.15152 47.21212
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  39.72414 40.03448 40.34483 40.65517 40.96552 41.27586 41.58621 41.89655
8  63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000
9  42.34884 42.86047 43.37209 43.88372 44.39535 44.90698 45.41860 45.93023
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000
13 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.59  TAVG.60  TAVG.61  TAVG.62  TAVG.63  TAVG.64  TAVG.65  TAVG.66
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  35.33846 35.55385 35.76923 35.98462 36.20000 36.41538 36.63077 36.84615
4  47.27273 47.33333 47.39394 47.45455 47.51515 47.57576 47.63636 47.69697
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  42.20690 42.51724 42.82759 43.13793 43.44828 43.75862 44.06897 44.37931
8  63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000
9  46.44186 46.95349 47.46512 47.97674 48.48837 49.00000 53.00000 57.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000
13 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.67  TAVG.68  TAVG.69  TAVG.70  TAVG.71  TAVG.72  TAVG.73  TAVG.74
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  37.06154 37.27692 37.49231 37.70769 37.92308 38.13846 38.35385 38.56923
4  47.75758 47.81818 47.87879 47.93939 48.00000 46.20000 44.40000 42.60000
5  17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615 17.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  44.68966 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000
8  63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000 63.00000
9  57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000 44.00000
13 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000 35.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667 26.16667
17 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000 22.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000 26.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000 25.00000
    TAVG.75  TAVG.76  TAVG.77  TAVG.78  TAVG.79   TMAX.1   TMAX.2   TMAX.3
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  38.78462 39.00000 39.00000 39.00000 39.00000 41.00000 44.00977 43.29808
4  40.80000 39.00000 39.00000 39.00000 39.00000 60.00000 60.00000 60.00000
5  17.84615 17.84615 17.84615 17.84615 17.84615 43.50000 43.50000 24.00000
6        NA       NA       NA       NA       NA       NA       NA       NA
7  45.00000 45.00000 45.00000 45.00000 45.00000 39.18901 39.18901 46.65185
8  63.00000 63.00000 63.00000 63.00000 63.00000 38.50000 38.50000 38.50000
9  57.00000 57.00000 57.00000 57.00000 57.00000 55.00000 55.00000 55.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 44.00000 44.00000 44.00000 44.00000 44.00000 55.00000 55.00000 55.00000
13 35.50000 35.50000 35.50000 35.50000 35.50000 55.00000 55.00000 55.00000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 26.16667 26.16667 26.16667 26.16667 26.16667 60.00000 60.00000 60.00000
17 22.00000 22.00000 22.00000 22.00000 22.00000 43.00000 43.00000 43.00000
18 26.00000 26.00000 26.00000 26.00000 26.00000 60.00000 60.00000 60.00000
19 25.00000 25.00000 25.00000 25.00000 25.00000 50.28571 50.28571 50.28571
     TMAX.4   TMAX.5   TMAX.6   TMAX.7   TMAX.8   TMAX.9  TMAX.10  TMAX.11
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  34.61111 50.44397 54.60000 21.00000 40.88889 29.25000 35.70588 40.00000
4  60.00000 60.00000 60.04545 60.09091 60.13636 60.18182 60.22727 60.27273
5  29.00000 51.28571 37.06593 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  27.30769 52.45455 35.72727 19.00000 29.10000 39.20000 34.00000 34.39655
8  38.50000 37.12500 35.75000 34.37500 33.00000 38.33333 37.28000 35.72222
9  42.49655 56.37255 60.00000 29.00000 35.52000 40.58294 37.31046 34.84615
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 55.00000 56.95062 57.80000 31.83333 32.00000 39.40000 34.60000 37.85714
13 55.00000 55.00000 56.18868 31.43137 32.91549 41.09524 34.33333 38.76923
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 60.00000 60.00000 52.54040 24.66667 31.66667 31.66667 31.66667 31.66667
17 43.00000 43.00000 56.77778 41.63889 26.50000 26.50000 26.50000 26.50000
18 60.00000 60.00000 47.50000 31.00000 25.20000 24.00000 30.00000 36.00000
19 50.28571 50.28571 49.41985 30.20000 43.00000 35.64286 34.00000 40.00000
    TMAX.12  TMAX.13  TMAX.14  TMAX.15  TMAX.16  TMAX.17  TMAX.18  TMAX.19
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  40.15385 40.30769 40.46154 40.61538 40.76923 40.92308 41.07692 41.23077
4  60.31818 60.36364 60.40909 60.45455 60.50000 60.54545 60.59091 60.63636
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  34.79310 35.18966 35.58621 35.98276 36.37931 36.77586 37.17241 37.56897
8  41.20000 45.00000 44.00000 43.00000 34.00000 35.40000 36.80000 38.20000
9  35.27692 35.70769 36.13846 36.56923 37.00000 37.25000 37.50000 37.75000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 43.16667 42.79545 39.49773 36.20000 32.00000 33.00000 34.00000 35.00000
13 42.00000 42.73684 38.56842 34.40000 38.00000 37.50000 37.00000 36.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.20  TMAX.21  TMAX.22  TMAX.23  TMAX.24  TMAX.25  TMAX.26  TMAX.27
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  41.38462 41.53846 41.69231 41.84615 42.00000 42.15385 42.30769 42.46154
4  60.68182 60.72727 60.77273 60.81818 60.86364 60.90909 60.95455 61.00000
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  37.96552 38.36207 38.75862 39.15517 39.55172 39.94828 40.34483 40.74138
8  39.60000 41.00000 29.00000 30.55000 32.10000 33.65000 35.20000 36.75000
9  38.00000 41.00000 41.39535 41.79070 42.18605 42.58140 42.97674 43.37209
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 36.00000 37.56897 34.45455 32.00000 30.00000 35.38462 30.50000 34.08333
13 36.00000 38.42457 33.04255 23.00000 29.50000 36.00000 30.50000 32.33714
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.28  TMAX.29  TMAX.30  TMAX.31  TMAX.32  TMAX.33  TMAX.34  TMAX.35
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  42.61538 42.76923 42.92308 43.07692 43.23077 43.38462 43.53846 43.69231
4  61.04545 61.09091 61.13636 61.18182 61.22727 61.27273 61.31818 61.36364
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  41.13793 41.53448 41.93103 42.32759 42.72414 43.12069 43.51724 43.91379
8  38.30000 39.85000 41.40000 42.95000 44.50000 46.05000 47.60000 49.15000
9  43.76744 44.16279 44.55814 44.95349 45.34884 45.74419 46.13953 46.53488
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 37.66667 41.25000 44.83333 48.41667 52.00000 43.74359 39.86047 48.77193
13 34.17429 36.01143 37.84857 39.68571 41.52286 43.36000 39.93443 48.32353
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.36  TMAX.37  TMAX.38  TMAX.39  TMAX.40  TMAX.41  TMAX.42  TMAX.43
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  43.84615 44.00000 44.15385 44.30769 44.46154 44.61538 44.76923 44.92308
4  61.40909 61.45455 61.50000 61.54545 61.59091 61.63636 61.68182 61.72727
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  44.31034 44.70690 45.10345 45.50000 45.89655 46.29310 46.68966 47.08621
8  50.70000 52.25000 53.80000 55.35000 56.90000 58.45000 60.00000 50.00000
9  46.93023 47.32558 47.72093 48.11628 48.51163 48.90698 49.30233 49.69767
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 57.21053 51.00000 45.85714 53.00000 51.01456 61.41638 52.86598 51.70000
13 57.47619 47.00000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.44  TMAX.45  TMAX.46  TMAX.47  TMAX.48  TMAX.49  TMAX.50  TMAX.51
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  45.07692 45.23077 45.38462 45.53846 45.69231 45.84615 46.00000 46.15385
4  61.77273 61.81818 61.86364 61.90909 61.95455 62.00000 62.04545 62.09091
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  47.48276 47.87931 48.27586 48.67241 49.06897 49.46552 49.86207 50.25862
8  62.00000 65.16667 68.33333 71.50000 74.66667 77.83333 81.00000 81.00000
9  50.09302 50.48837 50.88372 51.27907 51.67442 52.06977 52.46512 52.86047
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 60.85000 70.00000 63.50000 57.00000 57.00000 57.00000 57.00000 57.00000
13 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.52  TMAX.53  TMAX.54  TMAX.55  TMAX.56  TMAX.57  TMAX.58  TMAX.59
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  46.30769 46.46154 46.61538 46.76923 46.92308 47.07692 47.23077 47.38462
4  62.13636 62.18182 62.22727 62.27273 62.31818 62.36364 62.40909 62.45455
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  50.65517 51.05172 51.44828 51.84483 52.24138 52.63793 53.03448 53.43103
8  81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000
9  53.25581 53.65116 54.04651 54.44186 54.83721 55.23256 55.62791 56.02326
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000
13 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.60  TMAX.61  TMAX.62  TMAX.63  TMAX.64  TMAX.65  TMAX.66  TMAX.67
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  47.53846 47.69231 47.84615 48.00000 48.15385 48.30769 48.46154 48.61538
4  62.50000 62.54545 62.59091 62.63636 62.68182 62.72727 62.77273 62.81818
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  53.82759 54.22414 54.62069 55.01724 55.41379 55.81034 56.20690 56.60345
8  81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000
9  56.41860 56.81395 57.20930 57.60465 58.00000 67.50000 77.00000 77.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000
13 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.68  TMAX.69  TMAX.70  TMAX.71  TMAX.72  TMAX.73  TMAX.74  TMAX.75
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  48.76923 48.92308 49.07692 49.23077 49.38462 49.53846 49.69231 49.84615
4  62.86364 62.90909 62.95455 63.00000 60.40000 57.80000 55.20000 52.60000
5  22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615 22.84615
6        NA       NA       NA       NA       NA       NA       NA       NA
7  57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000
8  81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000 81.00000
9  77.00000 77.00000 77.00000 77.00000 77.00000 77.00000 77.00000 77.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000 57.00000
13 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000 45.75000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667 31.66667
17 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000 26.50000
18 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000 36.00000
19 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
    TMAX.76  TMAX.77  TMAX.78  TMAX.79   TMIN.1   TMIN.2   TMIN.3    TMIN.4
1        NA       NA       NA       NA       NA       NA       NA        NA
2        NA       NA       NA       NA       NA       NA       NA        NA
3  50.00000 50.00000 50.00000 50.00000 33.00000 27.84691 28.09615 11.185185
4  50.00000 50.00000 50.00000 50.00000 32.00000 32.00000 32.00000 32.000000
5  22.84615 22.84615 22.84615 22.84615 25.16667 25.16667 11.00000 11.000000
6        NA       NA       NA       NA       NA       NA       NA        NA
7  57.00000 57.00000 57.00000 57.00000 22.62064 22.62064 31.13333  7.846154
8  81.00000 81.00000 81.00000 81.00000 11.50000 11.50000 11.50000 11.500000
9  77.00000 77.00000 77.00000 77.00000 35.00000 35.00000 35.00000 13.372238
10       NA       NA       NA       NA       NA       NA       NA        NA
11       NA       NA       NA       NA       NA       NA       NA        NA
12 57.00000 57.00000 57.00000 57.00000 22.00000 22.00000 22.00000 22.000000
13 45.75000 45.75000 45.75000 45.75000 28.08451 28.08451 28.08451 28.084507
14       NA       NA       NA       NA       NA       NA       NA        NA
15       NA       NA       NA       NA       NA       NA       NA        NA
16 31.66667 31.66667 31.66667 31.66667 32.00000 32.00000 32.00000 32.000000
17 26.50000 26.50000 26.50000 26.50000 20.00000 20.00000 20.00000 20.000000
18 36.00000 36.00000 36.00000 36.00000 32.00000 32.00000 32.00000 32.000000
19 40.00000 40.00000 40.00000 40.00000 25.14286 25.14286 25.14286 25.142857
     TMIN.5   TMIN.6   TMIN.7   TMIN.8   TMIN.9  TMIN.10  TMIN.11  TMIN.12
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  25.27586 39.00000  0.00000 24.00000 14.25000 11.17647 12.00000 12.26154
4  32.00000 32.03030 32.06061 32.09091 32.12121 32.15152 32.18182 32.21212
5  26.85714 20.19780 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  29.03030 15.51515  2.00000 13.60000 25.20000 17.00000 17.34483 17.68966
8  15.12500 18.75000 22.37500 26.00000 15.00000 13.92000 14.16667 14.80000
9  29.08547 33.00000 22.00000 29.72000 19.33412 13.24837 14.30769 13.04615
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 30.00000 33.20000 21.00000 21.00000 23.72000 13.60000 13.00000 15.00000
13 28.08451 33.64151 19.78431 22.47887 26.19841 14.11111 12.92308 15.00000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 32.00000 37.93182  9.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 20.00000 38.77778 29.13889 19.50000 19.50000 19.50000 19.50000 19.50000
18 32.00000 32.00000 15.00000 13.20000 10.00000 11.50000 13.00000 13.00000
19 25.14286 32.73282 14.60000 25.00000 21.28571 17.00000 12.00000 12.00000
    TMIN.13  TMIN.14   TMIN.15  TMIN.16  TMIN.17  TMIN.18  TMIN.19  TMIN.20
1        NA       NA        NA       NA       NA       NA       NA       NA
2        NA       NA        NA       NA       NA       NA       NA       NA
3  12.52308 12.78462 13.046154 13.30769 13.56923 13.83077 14.09231 14.35385
4  32.24242 32.27273 32.303030 32.33333 32.36364 32.39394 32.42424 32.45455
5  13.53846 13.53846 13.538462 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA        NA       NA       NA       NA       NA       NA
7  18.03448 18.37931 18.724138 19.06897 19.41379 19.75862 20.10345 20.44828
8  22.00000 27.00000 32.000000 10.00000 12.40000 14.80000 17.20000 19.60000
9  11.78462 10.52308  9.261538  8.00000 10.00000 12.00000 14.00000 16.00000
10       NA       NA        NA       NA       NA       NA       NA       NA
11       NA       NA        NA       NA       NA       NA       NA       NA
12 18.54545 23.67273 28.800000 18.00000 18.00000 18.00000 18.00000 18.00000
13 18.94737 23.37368 27.800000 18.00000 18.00000 18.00000 18.00000 18.00000
14       NA       NA        NA       NA       NA       NA       NA       NA
15       NA       NA        NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.000000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.500000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.000000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.000000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.21  TMIN.22  TMIN.23  TMIN.24  TMIN.25  TMIN.26  TMIN.27  TMIN.28
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  14.61538 14.87692 15.13846 15.40000 15.66154 15.92308 16.18462 16.44615
4  32.48485 32.51515 32.54545 32.57576 32.60606 32.63636 32.66667 32.69697
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  20.79310 21.13793 21.48276 21.82759 22.17241 22.51724 22.86207 23.20690
8  22.00000 11.00000 11.90000 12.80000 13.70000 14.60000 15.50000 16.40000
9  19.00000 19.58140 20.16279 20.74419 21.32558 21.90698 22.48837 23.06977
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 15.94828 18.24242 20.00000 14.00000 10.15385 16.50000 17.58333 18.66667
13 17.18966 16.55319 11.00000 11.50000 12.00000 16.50000 17.18857 17.87714
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.29  TMIN.30  TMIN.31  TMIN.32  TMIN.33  TMIN.34  TMIN.35  TMIN.36
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  16.70769 16.96923 17.23077 17.49231 17.75385 18.01538 18.27692 18.53846
4  32.72727 32.75758 32.78788 32.81818 32.84848 32.87879 32.90909 32.93939
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  23.55172 23.89655 24.24138 24.58621 24.93103 25.27586 25.62069 25.96552
8  17.30000 18.20000 19.10000 20.00000 20.90000 21.80000 22.70000 23.60000
9  23.65116 24.23256 24.81395 25.39535 25.97674 26.55814 27.13953 27.72093
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 19.75000 20.83333 21.91667 23.00000 21.23077 18.93023 20.02632 29.10526
13 18.56571 19.25429 19.94286 20.63143 21.32000 19.29508 20.05882 29.28571
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.37  TMIN.38  TMIN.39  TMIN.40  TMIN.41  TMIN.42  TMIN.43  TMIN.44
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  18.80000 19.06154 19.32308 19.58462 19.84615 20.10769 20.36923 20.63077
4  32.96970 33.00000 33.03030 33.06061 33.09091 33.12121 33.15152 33.18182
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  26.31034 26.65517 27.00000 27.34483 27.68966 28.03448 28.37931 28.72414
8  24.50000 25.40000 26.30000 27.20000 28.10000 29.00000 25.00000 31.00000
9  28.30233 28.88372 29.46512 30.04651 30.62791 31.20930 31.79070 32.37209
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 20.00000 23.85714 25.00000 29.47087 31.84187 31.40722 29.25000 33.12500
13 16.00000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.45  TMIN.46  TMIN.47  TMIN.48  TMIN.49  TMIN.50  TMIN.51  TMIN.52
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  20.89231 21.15385 21.41538 21.67692 21.93846 22.20000 22.46154 22.72308
4  33.21212 33.24242 33.27273 33.30303 33.33333 33.36364 33.39394 33.42424
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  29.06897 29.41379 29.75862 30.10345 30.44828 30.79310 31.13793 31.48276
8  33.33333 35.66667 38.00000 40.33333 42.66667 45.00000 45.00000 45.00000
9  32.95349 33.53488 34.11628 34.69767 35.27907 35.86047 36.44186 37.02326
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 37.00000 35.50000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
13 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.53  TMIN.54  TMIN.55  TMIN.56  TMIN.57  TMIN.58  TMIN.59  TMIN.60
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  22.98462 23.24615 23.50769 23.76923 24.03077 24.29231 24.55385 24.81538
4  33.45455 33.48485 33.51515 33.54545 33.57576 33.60606 33.63636 33.66667
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  31.82759 32.17241 32.51724 32.86207 33.20690 33.55172 33.89655 34.24138
8  45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000
9  37.60465 38.18605 38.76744 39.34884 39.93023 40.51163 41.09302 41.67442
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
13 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.61  TMIN.62  TMIN.63  TMIN.64  TMIN.65  TMIN.66  TMIN.67  TMIN.68
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  25.07692 25.33846 25.60000 25.86154 26.12308 26.38462 26.64615 26.90769
4  33.69697 33.72727 33.75758 33.78788 33.81818 33.84848 33.87879 33.90909
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  34.58621 34.93103 35.27586 35.62069 35.96552 36.31034 36.65517 37.00000
8  45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000
9  42.25581 42.83721 43.41860 44.00000 42.00000 40.00000 40.00000 40.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
13 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.69  TMIN.70  TMIN.71  TMIN.72  TMIN.73  TMIN.74  TMIN.75  TMIN.76
1        NA       NA       NA       NA       NA       NA       NA       NA
2        NA       NA       NA       NA       NA       NA       NA       NA
3  27.16923 27.43077 27.69231 27.95385 28.21538 28.47692 28.73846 29.00000
4  33.93939 33.96970 34.00000 33.00000 32.00000 31.00000 30.00000 29.00000
5  13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846 13.53846
6        NA       NA       NA       NA       NA       NA       NA       NA
7  37.00000 37.00000 37.00000 37.00000 37.00000 37.00000 37.00000 37.00000
8  45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000 45.00000
9  40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000 40.00000
10       NA       NA       NA       NA       NA       NA       NA       NA
11       NA       NA       NA       NA       NA       NA       NA       NA
12 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000 34.00000
13 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000 24.50000
14       NA       NA       NA       NA       NA       NA       NA       NA
15       NA       NA       NA       NA       NA       NA       NA       NA
16 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000 12.00000
    TMIN.77  TMIN.78  TMIN.79
1        NA       NA       NA
2        NA       NA       NA
3  29.00000 29.00000 29.00000
4  29.00000 29.00000 29.00000
5  13.53846 13.53846 13.53846
6        NA       NA       NA
7  37.00000 37.00000 37.00000
8  45.00000 45.00000 45.00000
9  40.00000 40.00000 40.00000
10       NA       NA       NA
11       NA       NA       NA
12 34.00000 34.00000 34.00000
13 24.50000 24.50000 24.50000
14       NA       NA       NA
15       NA       NA       NA
16 19.00000 19.00000 19.00000
17 19.50000 19.50000 19.50000
18 13.00000 13.00000 13.00000
19 12.00000 12.00000 12.00000
summary(marten)
unmarkedFrame Object

19 sites
Maximum number of observations per site: 79 
Mean number of observations per site: 73.63 
Sites with at least one detection: 19 

Tabulation of y observations:
   0    1 <NA> 
1127  272  102 

Site-level covariates:
       deployment_id      sensor_height   elevation      ruggedness      
 WM01.2       : 1    Chest height: 8    Min.   :1923   Min.   :-13.0963  
 WM01.2 Ground: 1    Other       :11    1st Qu.:2191   1st Qu.: -2.1627  
 WM03.2       : 1                       Median :2311   Median : -0.8553  
 WM03.2 Ground: 1                       Mean   :2292   Mean   : -0.3879  
 WM04.2       : 1                       3rd Qu.:2402   3rd Qu.:  2.8648  
 WM04.2 Ground: 1                       Max.   :2459   Max.   :  4.0513  
 (Other)      :13                                                        

Observation-level covariates:
      PRCP              SNOW               SNWD              TAVG      
 Min.   :0.00000   Min.   :0.000000   Min.   :0.00000   Min.   :10.00  
 1st Qu.:0.00000   1st Qu.:0.000000   1st Qu.:0.00000   1st Qu.:25.00  
 Median :0.00000   Median :0.000000   Median :0.00000   Median :28.45  
 Mean   :0.05996   Mean   :0.003997   Mean   :0.06063   Mean   :32.40  
 3rd Qu.:0.00000   3rd Qu.:0.000000   3rd Qu.:0.00000   3rd Qu.:40.07  
 Max.   :1.00000   Max.   :1.000000   Max.   :1.00000   Max.   :63.00  
                                                        NA's   :553    
      TMAX            TMIN      
 Min.   :19.00   Min.   : 0.00  
 1st Qu.:31.67   1st Qu.:13.54  
 Median :40.00   Median :19.50  
 Mean   :43.26   Mean   :22.72  
 3rd Qu.:52.61   3rd Qu.:31.03  
 Max.   :81.00   Max.   :45.00  
 NA's   :553     NA's   :553    
plot(marten)

# run null model to get naive estimate of detection and occupancy
# i.e. one without covariates of either detection or occupancy
# note that the first ~1 is detection and the second ~1 is occupancy

ele_null <- occu(~1 ~1, marten)

# backtransform to get estimates

#detection
p_det <- backTransform(ele_null, "det")
p_det
Backtransformed linear combination(s) of Detection estimate(s)

 Estimate     SE LinComb (Intercept)
    0.194 0.0106   -1.42           1

Transformation: logistic 
# detection probability = 0.1944 (+/- SE 0.011)

# confidence intervals for detection
detCI <- confint(p_det)
detCI
     0.025     0.975
 0.1745199 0.2160032
# CI 95% 0.317 - 0.410

# occupancy
psi <- backTransform(ele_null, "state")
psi
Backtransformed linear combination(s) of Occupancy estimate(s)

 Estimate      SE LinComb (Intercept)
        1 0.00198    9.51           1

Transformation: logistic 
# naive occupancy = 0.895 (+/- SE 0.070) 

psiCI <- confint(psi)
psiCI
        0.025 0.975
 2.928727e-19     1
# CI 95% 0.663 - 0.974

So these outputs mean that: The null model gives a detection probability of 0.194 (SE 0.0106, 95% CI 0.175–0.216). The naïve occupancy estimate was high at 0.9999 (SE 0.0020), but the 95% confidence interval ranged from almost zero to one. This interval suggests that the null model cannot reliably determine how many sites were truly occupied. ## Model Fitting

colSums(is.na(siteCovs(marten)))
deployment_id sensor_height     elevation    ruggedness 
            0             0             0             0 
library(unmarked)

# -------------------------
# Detection-only models
# -------------------------

m.null         <- occu(~ 1 ~ 1, marten)
m.p.snwd       <- occu(~ SNWD ~ 1, marten)
m.p.prcp       <- occu(~ PRCP ~ 1, marten)
m.p.snwd.prcp  <- occu(~ SNWD + PRCP ~ 1, marten)

# -------------------------
# Occupancy-only models
# (no elevation + ruggedness together)
# -------------------------

m.psi.elev     <- occu(~ 1 ~ elevation, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.psi.rug      <- occu(~ 1 ~ ruggedness, marten)
m.psi.sh       <- occu(~ 1 ~ sensor_height, marten)

m.psi.elev.sh  <- occu(~ 1 ~ elevation + sensor_height, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.psi.rug.sh   <- occu(~ 1 ~ ruggedness + sensor_height, marten)

# -------------------------
# Combined models
# (valid combinations only)
# -------------------------

# SNWD as detection covariate
m.snwd.elev    <- occu(~ SNWD ~ elevation, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.snwd.rug     <- occu(~ SNWD ~ ruggedness, marten)
m.snwd.sh      <- occu(~ SNWD ~ sensor_height, marten)

m.snwd.elev.sh <- occu(~ SNWD ~ elevation + sensor_height, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.snwd.rug.sh  <- occu(~ SNWD ~ ruggedness + sensor_height, marten)

# PRCP as detection covariate
m.prcp.elev    <- occu(~ PRCP ~ elevation, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.prcp.rug     <- occu(~ PRCP ~ ruggedness, marten)
m.prcp.sh      <- occu(~ PRCP ~ sensor_height, marten)

m.prcp.elev.sh <- occu(~ PRCP ~ elevation + sensor_height, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.prcp.rug.sh  <- occu(~ PRCP ~ ruggedness + sensor_height, marten)

# SNWD + PRCP as detection covariates
m.snwdprcp.elev.sh <- occu(~ SNWD + PRCP ~ elevation + sensor_height, marten)
Warning: Hessian is singular. Try providing starting values or using fewer
covariates.
m.snwdprcp.rug.sh  <- occu(~ SNWD + PRCP ~ ruggedness + sensor_height, marten)

# -------------------------
# Model selection
# -------------------------

fits <- fitList(
  null              = m.null,
  p_snwd            = m.p.snwd,
  p_prcp            = m.p.prcp,
  p_snwd_prcp       = m.p.snwd.prcp,
  psi_elev          = m.psi.elev,
  psi_rug           = m.psi.rug,
  psi_sh            = m.psi.sh,
  psi_elev_sh       = m.psi.elev.sh,
  psi_rug_sh        = m.psi.rug.sh,
  snwd_elev         = m.snwd.elev,
  snwd_rug          = m.snwd.rug,
  snwd_sh           = m.snwd.sh,
  snwd_elev_sh      = m.snwd.elev.sh,
  snwd_rug_sh       = m.snwd.rug.sh,
  prcp_elev         = m.prcp.elev,
  prcp_rug          = m.prcp.rug,
  prcp_sh           = m.prcp.sh,
  prcp_elev_sh      = m.prcp.elev.sh,
  prcp_rug_sh       = m.prcp.rug.sh,
  snwdprcp_elev_sh  = m.snwdprcp.elev.sh,
  snwdprcp_rug_sh   = m.snwdprcp.rug.sh
)

modSel(fits)
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
                 nPars     AIC  delta   AICwt cumltvWt
p_snwd_prcp          4  932.14   0.00 7.9e-01     0.79
snwdprcp_rug_sh      6  936.14   4.00 1.1e-01     0.89
snwdprcp_elev_sh     6  936.14   4.00 1.1e-01     1.00
p_snwd               3 1057.66 125.53 4.3e-28     1.00
snwd_rug             4 1059.66 127.52 1.6e-28     1.00
snwd_sh              4 1059.66 127.52 1.6e-28     1.00
snwd_elev            4 1059.66 127.52 1.6e-28     1.00
p_prcp               3 1061.62 129.48 6.0e-29     1.00
snwd_elev_sh         5 1061.66 129.52 5.9e-29     1.00
snwd_rug_sh          5 1061.66 129.52 5.9e-29     1.00
prcp_rug             4 1063.61 131.47 2.2e-29     1.00
prcp_sh              4 1063.61 131.47 2.2e-29     1.00
prcp_elev            4 1063.61 131.47 2.2e-29     1.00
prcp_elev_sh         5 1065.61 133.47 8.2e-30     1.00
prcp_rug_sh          5 1065.61 133.47 8.2e-30     1.00
null                 2 1382.23 450.09 1.4e-98     1.00
psi_elev             3 1384.23 452.09 5.3e-99     1.00
psi_sh               3 1384.23 452.09 5.3e-99     1.00
psi_rug              3 1384.23 452.09 5.3e-99     1.00
psi_elev_sh          4 1386.23 454.09 2.0e-99     1.00
psi_rug_sh           4 1386.24 454.10 1.9e-99     1.00
library(gt)

Attaching package: 'gt'
The following objects are masked from 'package:Hmisc':

    html, latex
ms_raw <- modSel(fits)@Full
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
Hessian is singular.
# Updated model labels to match your cleaned model list
model_labels <- c(
  null               = "Null model",
  p_snwd             = "Detection ~ snow depth",
  p_prcp             = "Detection ~ precipitation",
  p_snwd_prcp        = "Detection ~ snow depth + precipitation",
  
  psi_elev           = "Occupancy ~ elevation",
  psi_rug            = "Occupancy ~ ruggedness",
  psi_sh             = "Occupancy ~ sensor height",
  psi_elev_sh        = "Occupancy ~ elevation + sensor height",
  psi_rug_sh         = "Occupancy ~ ruggedness + sensor height",
  
  snwd_elev          = "Det ~ snow depth; Occ ~ elevation",
  snwd_rug           = "Det ~ snow depth; Occ ~ ruggedness",
  snwd_sh            = "Det ~ snow depth; Occ ~ sensor height",
  snwd_elev_sh       = "Det ~ snow depth; Occ ~ elevation + sensor height",
  snwd_rug_sh        = "Det ~ snow depth; Occ ~ ruggedness + sensor height",
  
  prcp_elev          = "Det ~ precipitation; Occ ~ elevation",
  prcp_rug           = "Det ~ precipitation; Occ ~ ruggedness",
  prcp_sh            = "Det ~ precipitation; Occ ~ sensor height",
  prcp_elev_sh       = "Det ~ precipitation; Occ ~ elevation + sensor height",
  prcp_rug_sh        = "Det ~ precipitation; Occ ~ ruggedness + sensor height",
  
  snwdprcp_elev_sh   = "Det ~ snow depth + precipitation; Occ ~ elevation + sensor height",
  snwdprcp_rug_sh    = "Det ~ snow depth + precipitation; Occ ~ ruggedness + sensor height"
)

# Build the cleaned model selection dataframe
ms_df <- ms_raw %>%
  select(model, AIC, delta, AICwt) %>%
  mutate(model = model_labels[model])   # apply readable names

# Build the GT table
gt_table <- ms_df %>%
  arrange(AIC) %>%
  gt(rowname_col = "model") %>%
  tab_stubhead(label = "Model") %>%
  tab_header(
    title = "Model Selection Table",
    subtitle = "AIC comparison of candidate occupancy models"
  ) %>%
  fmt_number(
    columns = c(AIC, delta, AICwt),
    decimals = 3
  ) %>%
  cols_label(
    AIC = "AIC",
    delta = "ΔAIC",
    AICwt = "AIC Weight"
  )

# Export the table
gtsave(
  gt_table,
  "C:/Users/coope/Documents/MSc Applied Ecology and Geospatial Techniques/Applied Pop Biol/wildlife-insights_240a773a-6a71-474a-ae0b-afed6661f231_all-platform-data/model_selection_table(marten_all).png"
)
file:///C:/Users/coope/AppData/Local/Temp/RtmpQf0MMS/file2c60526860fe.html screenshot completed
summary(m.p.snwd.prcp)

Call:
occu(formula = ~SNWD + PRCP ~ 1, data = marten)

Occupancy (logit-scale):
 Estimate  SE    z P(>|z|)
     12.2 101 0.12   0.904

Detection (logit-scale):
            Estimate       SE       z   P(>|z|)
(Intercept)    -2.02   0.0869 -23.203 4.22e-119
SNWD           14.68  99.5545   0.147  8.83e-01
PRCP           14.92 113.6505   0.131  8.96e-01

AIC: 932.1377 
Number of sites: 19
Warning: Large or missing SE values. Be very cautious using these results.

Conclusions so far

This tells us that snow on the ground and precipitation affects detection but not occupancy. This was true for both the winter only data and all the data for the Pacific Marten

This supports the null hypothesis that none of the co-variates are important in telling us where the martens are found, this was true for both full year and winter only data, however the confidence of the detection was far lower for all year data when compared to winter only. This makes sense as the detection of martens was higher when there was snow on the ground, however the uncertainty was so high that this conclusion is only weakly supported.

Lack of individual identification means that home range size or number of territories cannot be examined. As we are investigating the factors affecting distributions, rather than explicit numbers, the closed population assumption can be violated.

Wolverine Occupancy - single species, multiple season

rm(list = ls())
# Detach all non-base packages
detach_all_packages <- function() {
  basic.packages <- c("package:stats", "package:graphics", "package:grDevices",
                      "package:utils", "package:datasets", "package:methods", "package:base")
  
  loaded <- search()[grepl("^package:", search())]
  to.detach <- setdiff(loaded, basic.packages)
  
  for(pkg in to.detach) {
    detach(pkg, character.only = TRUE, unload = TRUE)
  }
}

# Run it
detach_all_packages()
Warning: 'knitr' namespace cannot be unloaded:
  namespace 'knitr' is imported by 'htmlTable', 'rmarkdown' so cannot be unloaded
library(readr)
library(lubridate)

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(knitr)
library(kableExtra)

Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':

    group_rows
library(tidyr)
#| label: Calling the wolverine Data

deployments<-read.csv("deployment+covariates.csv")
wolverine_img<-read.csv("images+covariates.csv")%>%
  filter(genus == "Gulo")

Now we have the data, lets start the prep:

# Step 1: Convert start_date and end_date to Date format
deployments$start_date <- as.Date(deployments$start_date, format = "%Y-%m-%d")
deployments$end_date   <- as.Date(deployments$end_date,   format = "%Y-%m-%d")

# Step 2: Expand deployments into daily records
deployments_days <- deployments %>%
  rowwise() %>%
  mutate(day_seq = list(seq.Date(start_date, end_date, by = "day"))) %>%
  ungroup() %>%
  select(deployment_id, day_seq) %>%
  tidyr::unnest(day_seq)

# Step 3: Assign each day to a biologically relevant season
deployment_subset <- deployments_days %>%
  mutate(
    month = month(day_seq),
    season = case_when(
      month %in% c(12, 1, 2) ~ "Winter survival/caching",
      month %in% c(2, 3, 4)  ~ "Denning/birth",
      month %in% c(5, 6)     ~ "Late kit rearing",
      month %in% c(7, 8)     ~ "Summer foraging",
      month %in% c(9, 10, 11) ~ "Autumn dispersal/caching",
      TRUE ~ NA_character_
    )
  )


# Step 4: Collapse back to deployment ranges 
deployment_data <- deployment_subset %>%
  group_by(deployment_id) %>%
  summarise(
    start_date = min(day_seq),
    end_date   = max(day_seq),
    .groups = "drop"
  )

# Step 5: Define global study period and partition length
overall_start_date <- min(deployment_data$start_date)
overall_end_date   <- max(deployment_data$end_date)

period_length <- 5
total_periods <- ceiling(
  as.numeric(difftime(overall_end_date, overall_start_date, units = "days")) /
    period_length
)

# Step 6: Create dynamic SO columns
so_columns <- paste0("SO", 1:total_periods)

so_df <- data.frame(
  deployment_id = character(),
  matrix(NA, nrow = 0, ncol = total_periods),
  start_date = as.Date(character()),
  end_date   = as.Date(character()),
  stringsAsFactors = FALSE
)

colnames(so_df)[2:(total_periods + 1)] <- so_columns

# Step 7: Loop through deployments and mark SO periods (1 = active)
for (index in 1:nrow(deployment_data)) {
  
  deployment_id <- deployment_data$deployment_id[index]
  start_date    <- deployment_data$start_date[index]
  end_date      <- deployment_data$end_date[index]
  
  period_flags <- rep(0, total_periods)
  
  for (period in 0:(total_periods - 1)) {
    
    period_start <- overall_start_date + days(period * period_length)
    period_end   <- period_start + days(period_length - 1)
    
    if (period_end >= start_date && period_start <= end_date) {
      period_flags[period + 1] <- 1
    }
  }
  
  so_df <- rbind(
    so_df,
    data.frame(
      deployment_id = deployment_id,
      start_date = start_date,
      end_date = end_date,
      setNames(as.list(period_flags), so_columns),
      stringsAsFactors = FALSE
    )
  )
}

# Step 8: Order deployments by start date
so_df <- so_df %>% arrange(start_date)

# Step 9: Inspect
head(so_df, 10)
     deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9
1           WM01.2 2020-10-08 2021-10-19   1   1   1   1   1   1   1   1   1
2    WM01.2 Ground 2020-10-08 2021-10-19   1   1   1   1   1   1   1   1   1
3           WM03.2 2020-10-09 2021-10-19   1   1   1   1   1   1   1   1   1
4    WM03.2 Ground 2020-10-09 2021-10-19   1   1   1   1   1   1   1   1   1
5           WM08.2 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
6    WM08.2 Ground 2020-10-09 2021-10-20   1   1   1   1   1   1   1   1   1
7  WM14 10/12/2020 2020-10-12 2021-09-25   1   1   1   1   1   1   1   1   1
8    WM12.1 Ground 2020-10-13 2021-10-12   0   1   1   1   1   1   1   1   1
9           WM12.1 2020-10-14 2021-10-12   0   1   1   1   1   1   1   1   1
10          WM04.2 2020-10-19 2021-10-30   0   0   1   1   1   1   1   1   1
   SO10 SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO25 SO26 SO27 SO28 SO29 SO30 SO31 SO32 SO33 SO34 SO35 SO36 SO37 SO38 SO39
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO40 SO41 SO42 SO43 SO44 SO45 SO46 SO47 SO48 SO49 SO50 SO51 SO52 SO53 SO54
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO55 SO56 SO57 SO58 SO59 SO60 SO61 SO62 SO63 SO64 SO65 SO66 SO67 SO68 SO69
1     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
2     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
3     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
4     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
5     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
6     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
7     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
8     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
9     1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
10    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1
   SO70 SO71 SO72 SO73 SO74 SO75 SO76 SO77 SO78
1     1    1    1    1    1    1    1    0    0
2     1    1    1    1    1    1    1    0    0
3     1    1    1    1    1    1    1    0    0
4     1    1    1    1    1    1    1    0    0
5     1    1    1    1    1    1    1    0    0
6     1    1    1    1    1    1    1    0    0
7     1    1    0    0    0    0    0    0    0
8     1    1    1    1    1    0    0    0    0
9     1    1    1    1    1    0    0    0    0
10    1    1    1    1    1    1    1    1    1

Detection matrix:

# Step 1: Ensure detection timestamps are Date format
wolverine_img <- wolverine_img %>%
  mutate(timestamp = as.Date(timestamp, format = "%Y-%m-%d"))

# Step 2: Identify SO columns
so_cols <- grep("^SO", names(so_df), value = TRUE)

# Step 3: Build lookup table of SO block ranges
so_blocks <- data.frame(
  SO = so_cols,
  block_start = overall_start_date + days((seq_along(so_cols) - 1) * period_length),
  block_end   = overall_start_date + days((seq_along(so_cols) - 1) * period_length + (period_length - 1))
)

# Step 4: Initialise detection matrix
detection_matrix <- so_df

# Step 5: Fill detection matrix
for (i in seq_len(nrow(so_blocks))) {
  
  so_name     <- so_blocks$SO[i]
  block_start <- so_blocks$block_start[i]
  block_end   <- so_blocks$block_end[i]
  
  detection_matrix[[so_name]] <- sapply(detection_matrix$deployment_id, function(dep_id) {
    any(
      wolverine_img$deployment_id == dep_id &
      wolverine_img$timestamp >= block_start &
      wolverine_img$timestamp <= block_end
    )
  }) |> as.integer()
}

# Step 6: Inspect
head(detection_matrix, 10)
     deployment_id start_date   end_date SO1 SO2 SO3 SO4 SO5 SO6 SO7 SO8 SO9
1           WM01.2 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
2    WM01.2 Ground 2020-10-08 2021-10-19   0   0   0   0   0   0   0   0   0
3           WM03.2 2020-10-09 2021-10-19   0   0   0   0   0   0   0   0   0
4    WM03.2 Ground 2020-10-09 2021-10-19   0   0   0   0   0   0   0   0   0
5           WM08.2 2020-10-09 2021-10-20   0   0   0   0   0   1   0   0   0
6    WM08.2 Ground 2020-10-09 2021-10-20   0   0   0   0   0   0   0   0   0
7  WM14 10/12/2020 2020-10-12 2021-09-25   0   0   0   0   0   0   0   0   0
8    WM12.1 Ground 2020-10-13 2021-10-12   0   0   1   1   0   0   0   0   0
9           WM12.1 2020-10-14 2021-10-12   0   0   1   1   0   0   0   0   0
10          WM04.2 2020-10-19 2021-10-30   0   0   0   0   0   0   0   0   0
   SO10 SO11 SO12 SO13 SO14 SO15 SO16 SO17 SO18 SO19 SO20 SO21 SO22 SO23 SO24
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    1    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    1    1    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    1    0    0    0    0    0    0    0    0    1    1    0    0
8     0    1    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    1    0    0    0    0    0    0    0    0    0    1    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO25 SO26 SO27 SO28 SO29 SO30 SO31 SO32 SO33 SO34 SO35 SO36 SO37 SO38 SO39
1     0    0    0    0    0    1    1    0    0    0    0    0    0    0    1
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    1
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    1    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    1    0    0    0    0    0    0    0    0
7     1    0    0    1    0    0    0    1    0    0    0    1    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    1    0    1
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO40 SO41 SO42 SO43 SO44 SO45 SO46 SO47 SO48 SO49 SO50 SO51 SO52 SO53 SO54
1     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     1    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    1    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    1    0    0    0    0    1    0    0    0    1    0    0
7     0    0    0    0    1    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO55 SO56 SO57 SO58 SO59 SO60 SO61 SO62 SO63 SO64 SO65 SO66 SO67 SO68 SO69
1     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
7     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
   SO70 SO71 SO72 SO73 SO74 SO75 SO76 SO77 SO78
1     0    0    0    0    0    0    0    0    0
2     0    0    0    0    0    0    0    0    0
3     0    0    0    0    0    0    0    0    0
4     0    0    0    0    0    0    0    0    0
5     0    0    0    0    0    0    0    0    0
6     0    0    0    0    0    1    0    0    0
7     0    0    0    0    0    0    0    0    0
8     0    0    0    0    0    0    0    0    0
9     0    0    0    0    0    0    0    0    0
10    0    0    0    0    0    0    0    0    0
sum(is.na(detection_matrix))
[1] 0

There are no NAs so no clean required here.

For this part, we want to assess occupation by season to see if there is variation - a single-species, multi-season model.

# Compute midpoint date for each SO block
so_blocks <- so_blocks %>%
  mutate(
    midpoint = block_start + floor((block_end - block_start) / 2),
    month = month(midpoint),
    season = case_when(
      month %in% c(12, 1, 2) ~ "Winter survival/caching",
      month %in% c(2, 3, 4)  ~ "Denning/birth",
      month %in% c(5, 6)     ~ "Late kit rearing",
      month %in% c(7, 8)     ~ "Summer foraging",
      month %in% c(9, 10, 11) ~ "Autumn dispersal/caching"
    )
  )

Create sample occasions within the season

# Join season info to detection matrix column names
so_season_map <- so_blocks %>% select(SO, season)

# List of SO columns per season
season_SO_list <- split(so_season_map$SO, so_season_map$season)

As the sample periods are uneven, this will create an issue with the unmarked object.

This is the compressed chunk that achieves this

# Count SO blocks per season
blocks_per_season <- sapply(season_SO_list, length)

# Minimum number of blocks across seasons
min_blocks <- min(blocks_per_season)

# Number to drop from each end (symmetric)
drop_each_side <- floor((blocks_per_season - min_blocks) / 2)

# Symmetric trimming + enforce exact length
season_SO_list_trimmed <- mapply(
  function(cols, drop_n) {
    # Step 1: symmetric trimming
    if (drop_n > 0) {
      cols <- cols[(drop_n + 1):(length(cols) - drop_n)]
    }
    # Step 2: enforce exact min_blocks (drop from end)
    if (length(cols) > min_blocks) {
      cols <- cols[1:min_blocks]
    }
    cols
  },
  season_SO_list,
  drop_each_side,
  SIMPLIFY = FALSE
)

and the checks:

sapply(season_SO_list_trimmed, length)
Autumn dispersal/caching            Denning/birth         Late kit rearing 
                      12                       12                       12 
         Summer foraging  Winter survival/caching 
                      12                       12 

And now we create the matrix:

# Order seasons
season_order <- c(
  "Winter survival/caching",
  "Denning/birth",
  "Late kit rearing",
  "Summer foraging",
  "Autumn dispersal/caching"
)

# Build y matrix by binding SO blocks in season order
y_multi <- do.call(
  cbind,
  lapply(season_order, function(s) {
    so_cols <- season_SO_list_trimmed[[s]]
    detection_matrix[, so_cols, drop = FALSE]
  })
)

and the effort matrix to go with it:

effort_multi <- do.call(
  cbind,
  lapply(season_order, function(s) {
    so_cols <- season_SO_list_trimmed[[s]]
    so_df[, so_cols, drop = FALSE] %>%
      mutate(across(everything(), ~ ifelse(is.na(.), 0, .)))
  })
)

and deployment covariates:

deployment_covariates <- deployments %>%
  select(deployment_id, sensor_height, elevation, ruggedness) %>%
  mutate(
    sensor_height_num = ifelse(
      is.na(sensor_height), 1,
      ifelse(sensor_height == "Other", 0, 1)
    )
  ) %>%
  select(-sensor_height) %>%
  slice(match(detection_matrix$deployment_id, deployment_id))

nrow(deployment_covariates)
[1] 19
nrow(y_multi)
[1] 19

Structure checks before passing to unmarked:

#remove deployment_id as a variable
deployment_covariates$deployment_id <- NULL

#check structure
str(deployment_covariates)
'data.frame':   19 obs. of  3 variables:
 $ elevation        : int  2311 2311 2402 2402 2459 2459 1923 2375 2375 2209 ...
 $ ruggedness       : num  -2.08 -2.08 2.86 2.86 3.1 ...
 $ sensor_height_num: num  0 1 0 1 0 0 0 1 0 0 ...

all blocks are now even - yay!

and the unmarked object:

library(unmarked)
umf_wolv <- unmarkedMultFrame(
  y = y_multi,
  siteCovs = deployment_covariates,
  yearlySiteCovs = NULL,
  obsCovs = list(effort = effort_multi),
  numPrimary = length(season_order)
)
summary(umf_wolv)
unmarkedFrame Object

19 sites
Maximum number of observations per site: 60 
Mean number of observations per site: 60 
Number of primary survey periods: 5 
Number of secondary survey periods: 12 
Sites with at least one detection: 13 

Tabulation of y observations:
   0    1 
1092   48 

Site-level covariates:
   elevation      ruggedness       sensor_height_num
 Min.   :1923   Min.   :-13.0963   Min.   :0.0000   
 1st Qu.:2191   1st Qu.: -2.1627   1st Qu.:0.0000   
 Median :2311   Median : -0.8553   Median :0.0000   
 Mean   :2292   Mean   : -0.3879   Mean   :0.4211   
 3rd Qu.:2402   3rd Qu.:  2.8648   3rd Qu.:1.0000   
 Max.   :2459   Max.   :  4.0513   Max.   :1.0000   

Observation-level covariates:
     effort      
 Min.   :0.0000  
 1st Qu.:1.0000  
 Median :1.0000  
 Mean   :0.9991  
 3rd Qu.:1.0000  
 Max.   :1.0000  
plot(umf_wolv)

We can see now where and when our observations are.

lets check co-linearity between the variates:

# Extract numeric site covariates
siteCovs <- deployment_covariates

# Define the pairs
pairs <- list(
  c("elevation", "ruggedness"),
  c("elevation", "sensor_height_num"),
  c("ruggedness", "sensor_height_num")
)

# Run cor.test() for each pair and extract results
cor_results <- lapply(pairs, function(vars) {
  x <- siteCovs[[vars[0 + 1]]]
  y <- siteCovs[[vars[1 + 1]]]
  test <- cor.test(x, y)
  
  data.frame(
    var1 = vars[0 + 1],
    var2 = vars[1 + 1],
    correlation = unname(test$estimate),
    p_value = test$p.value,
    conf_low = test$conf.int[1],
    conf_high = test$conf.int[2]
  )
})

# Combine into a single table
cor_table <- do.call(rbind, cor_results)
cor_table
        var1              var2 correlation      p_value   conf_low conf_high
1  elevation        ruggedness  0.92947029 8.829729e-09  0.8224985 0.9729327
2  elevation sensor_height_num  0.01398884 9.546737e-01 -0.4430354 0.4652420
3 ruggedness sensor_height_num  0.07965490 7.458233e-01 -0.3886145 0.5152234

As before, we can see a high co linearity between elevation and ruggedness so we can drop one of these within our models.

bug fixing the unmarked object creation

names(siteCovs(umf_wolv))
[1] "elevation"         "ruggedness"        "sensor_height_num"
names(yearlySiteCovs(umf_wolv))
NULL
names(obsCovs(umf_wolv))
[1] "effort"
colnames(umf_wolv@siteCovs)
[1] "elevation"         "ruggedness"        "sensor_height_num"
colnames(umf_wolv@yearlySiteCovs)
NULL
colnames(umf_wolv@obsCovs)
[1] "effort"
colnames(y_multi)
 [1] "SO15" "SO16" "SO17" "SO18" "SO19" "SO20" "SO21" "SO22" "SO23" "SO24"
[11] "SO25" "SO26" "SO30" "SO31" "SO32" "SO33" "SO34" "SO35" "SO36" "SO37"
[21] "SO38" "SO39" "SO40" "SO41" "SO42" "SO43" "SO44" "SO45" "SO46" "SO47"
[31] "SO48" "SO49" "SO50" "SO51" "SO52" "SO53" "SO54" "SO55" "SO56" "SO57"
[41] "SO58" "SO59" "SO60" "SO61" "SO62" "SO63" "SO64" "SO65" "SO6"  "SO7" 
[51] "SO8"  "SO9"  "SO10" "SO11" "SO67" "SO68" "SO69" "SO70" "SO71" "SO72"
lapply(umf_wolv@siteCovs, class)
$elevation
[1] "integer"

$ruggedness
[1] "numeric"

$sensor_height_num
[1] "numeric"
any(is.na(deployment_covariates$elevation))
[1] FALSE
any(is.na(deployment_covariates$ruggedness))
[1] FALSE
any(is.na(deployment_covariates$sensor_height_num))
[1] FALSE
umf_wolv@numPrimary
[1] 5
ncol(y_multi)
[1] 60
ncol(y_multi) / umf_wolv@numPrimary
[1] 12
rownames(umf_wolv@siteCovs)
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
[16] "16" "17" "18" "19"
rownames(y_multi)
 [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
[16] "16" "17" "18" "19"
args(colext)
function (psiformula = ~1, gammaformula = ~1, epsilonformula = ~1, 
    pformula = ~1, data, starts, method = "BFGS", se = TRUE, 
    ...) 
NULL

Sigh - argument issue not data issue!!!

Lets run the null model:

m0 <- colext(
  psiformula      = ~1,
  gammaformula    = ~1,
  epsilonformula  = ~1,
  pformula        = ~1,
  data = umf_wolv
)

# Extract parameter estimates 
occupancy_est     <- backTransform(m0, type = "psi")   # Occupancy probability
colonization_est  <- backTransform(m0, type = "col")   # Colonisation probability
extinction_est    <- backTransform(m0, type = "ext")   # Extinction probability
detection_est     <- backTransform(m0, type = "det")   # Detection probability

# Print the estimates
cat("Occupancy probability (psi):", occupancy_est@estimate, "\n")
Occupancy probability (psi): 0.6036841 
cat("Colonisation probability (gamma):", colonization_est@estimate, "\n")
Colonisation probability (gamma): 0.07561866 
cat("Extinction probability (epsilon):", extinction_est@estimate, "\n")
Extinction probability (epsilon): 6.054347e-05 
cat("Detection probability (p):", detection_est@estimate, "\n")
Detection probability (p): 0.0647397 

Wolverine colcusions so far

Sites surveyed were roughly 60% occupied (psi) Colonisation is low (0.075) Extinction is >0.001 There is a low detection probability.

This all makes sense - Wolverines are solitary animals with large territories and so the whole survey site may only have included a single animal.There was only one identified by teh orginal study.

comparisions between Martens and Wolverines:

There is a larger proportion of sites occupied by Martens than Wolverines The probability of detecting Martens in higher than that of wolverines.

We cannot tell, without individual IDs,

To help with assessing the studies design, examining how the detection between cameras that were ground or higher mounted would be interesting.

m_p_height <- colext(
  psiformula      = ~1,
  gammaformula    = ~1,
  epsilonformula  = ~1,
  pformula        = ~ sensor_height_num,
  data = umf_wolv
)

# Extract detection coefficients
b0 <- coef(m_p_height, type = "det")[1]   # intercept
b1 <- coef(m_p_height, type = "det")[2]   # effect of sensor height

# Logistic function
invlogit <- function(x) 1 / (1 + exp(-x))

# Detection for other height (0)
p_other <- invlogit(b0)

# Detection for standard height (1)
p_standard <- invlogit(b0 + b1)

cat("=== DETECTION ~ SENSOR HEIGHT MODEL ===\n")
=== DETECTION ~ SENSOR HEIGHT MODEL ===
cat("Detection (other height):",    p_other, "\n")
Detection (other height): 0.08182376 
cat("Detection (standard height):", p_standard, "\n")
Detection (standard height): 0.07733799 

This is interesting - there is little difference between the detection of wolverines regardless of camera height.

Between species comparisions

We can see from the detection maps that there is overlap between the detections of the scavengers.