Abstract

Black bass in California’s Sacramento–San Joaquin Delta may negatively impact the recovery of listed native species. Knowledge of their spatial distribution patterns and habitat associations may help inform restoration and management. The primary goal of this project is to determine whether catch rates are spatially autocorrelated within the study area and whether the patterns and magnitude of spatial clusters change over time. This project will examine the spatial distribution of black bass catch rates across a multiyear electrofishing dataset collected by the US Fish and Wildlife Service at randomly selected sites in the north-central Delta from 2021 to 2026. The analysis will use Global Moran’s I to evaluate overall spatial autocorrelation and Local Moran’s I to identify local clusters of similar values and spatial outliers. Maps of catch rates each year compared to environmental variables show that… This project may fill knowledge gaps in the spatial patterns of black bass occupancy across the north-central Delta over a multi-year time span across a range of environmental conditions.

Introduction

Black bass (Micropterus spp.; largemouth, smallmouth, redeye, Florida, and spotted bass) are invasive species throughout much of California and a predator of listed native species, such as Delta smelt (Hypomesus transpacificus) and Chinook salmon (Oncorhynchus tshawytscha; Moyle, 2002). Native fish species have experienced declines in California and juvenile Chinook salmon have very poor survival through the Sacramento–San Joaquin Delta during their migration from rivers to the ocean; sometimes close to zero survive (Michel et al., 2015). Black bass and other non-native species are abundant in this area, but not frequently the target of studies that focus on their habitat associations. Understanding where fish occurrences are concentrated can help describe spatial variation in populations and identify areas that may warrant further monitoring or inform restoration planning.

This project will use black bass electrofishing data to investigate the spatial distribution of catch rates across the study area. A global Moran’s I will determine if there is spatial autocorrelation in black bass catch rates throughout the study area. Local Moran’s I will determine where hotspots, cold spots, and outliers occur across years. Spatial clustering analysis of environmental variables such as bank type, substrate, conductivity, temperature, and dissolved oxygen will be compared to black bass catch patterns to see if there is any overlap. However, Moran’s I of catch rates does not test whether habitat characteristics cause or statistically explain the observed occurrence patterns. The project’s research questions are: 1. Are black bass catch rates geographically clustered across sampling locations? 2. Do areas with higher or lower catch rates coincide with particular habitat characteristics?

Data

This project will use data from the US Fish and Wildlife Service Interagency Ecological Program’s Delta Boat Electrofishing Survey from 2021 to 2026 (IEP, 2026), which is publicly available for download from the EDI Data Portal at: https://doi.org/10.6073/pasta/1e762637531d8b20a4a3b25361b3ab1f. This dataset includes species catch, effort, coordinates, and environmental data from each site.

This sampling program used a stratified random sampling design and segmented transects, so occupancy should show spatial correlation rather than sampling biases. However, effort and spatial coverage may vary by season and year. Catch will be described per unit effort, including sites with zero black bass catch. This analysis will include examination of the number and distribution of sampled locations each year to determine gaps in sampling coverage.

Methodology

Data preparation and analyses were conducted in R (R Core Team, 2025) using the spdep (Bivand and Wong, 2018) and sf (Pebesma, 2018) packages. Large language models were used for limited code generation and background research on analytical approaches (OpenAI, 2026). Data preparation included summing black bass catch per site, creating a unique site number for each distinct date, start time and location sampled, and summing of effort in seconds per site. Sites with missing location information were excluded from further analyses (n=1). A summary table was created to compare the total sites sampled and catch rates across years. Catch per unit effort (CPUE) was calculated by dividing the total black bass catch per site by the total site effort in seconds. A mid point for each site was determined from the start and end coordinates of the middle segment of each site. Catch rates for each site were combined with the site coordinates using the unique site number so that the order of each was concordant. Site coordinates were projected to NAD83/UTM zone 10N (EPSG: 26910; meters) and transformed into a spatial object.


Load packages and import data

# Load packages
library(tidyr)
library(dplyr)
library(ggplot2)
library(lubridate)
library(openxlsx)
library(flextable)

# Import raw data
efish_data <- read.csv("Data/2021-2026_USFWS_EFISH_data.csv")

Tidy data and dates

# Tidy column names and select columns needed
clean_data <- efish_data %>% 
  rename(Date= SampleDate, Region = RegionCode, DO= DOChannel, Temp= TempChannel, 
         Turbidity= WaterTurbidityNTU, Cond= SpecConductance, Segment= 
           SegmentNumber, Effort= SecondsPerSegment, StartLat= LatitudeStart, 
         StartLong= LongitudeStart, EndLat= LatitudeEnd, EndLong= LongitudeEnd,
         StartDepth= WaterDepthStart, EndDepth= WaterDepthEnd, Substrate= 
           SubstrateSegment) %>% 
  select(Date, StartTime, StopTime, StartLat, StartLong, EndLat, EndLong, 
         Segment, Effort, OrganismCode, ForkLength, Dead,
         Count, Region, Subregion, Tide, Temp, DO, Cond, Turbidity, Emergent, 
         Floating, LWD, SAV, Substrate, BankType,  Comments)

# Make sure date is correct and make year and month columns
clean_data$Date <- mdy(clean_data$Date)

clean_data <- clean_data %>% 
  mutate(Year= year(Date), Month= month(Date))

# Convert start time to time format
clean_data <- clean_data %>%
  mutate(StartTime = hm(StartTime))

Create site numbers, calculate catch and effort per site

# Create a lookup table of unique sampling events
site_numbers <- clean_data %>%
  distinct(Date, StartTime) %>%
  arrange(Date, StartTime) %>%
  mutate(Site = row_number())

# Add site numbers to original data
clean_data <- clean_data %>%
  left_join(site_numbers, by = c("Date", "StartTime"))

# Calculate combined black bass catch by segment
bass_catch <- clean_data %>%
  filter(OrganismCode %in% c("BAS", "LMB", "SPB", "REB", "SMB")) %>%
  group_by(Site) %>%
  summarise(BlackBass = sum(Count, na.rm = TRUE), .groups = "drop")

# Create new data frame with all original sites and columns
site_catch <- clean_data %>%
  distinct(Site, .keep_all = TRUE) %>%
  select(-OrganismCode, -Count) %>%
  left_join(bass_catch, by = c("Site")) %>%
  mutate(BlackBass = coalesce(BlackBass, 0))

# Calculate total effort per site
site_effort <- clean_data %>%
  distinct(Site, StartLat, StartLong, EndLat, EndLong, .keep_all = TRUE) %>%
  group_by(Site) %>%
  summarise(TotalEffort = sum(Effort, na.rm = TRUE), .groups = "drop")

# Join to catch data and calculate CPUE at each site
site_catch <- site_catch %>%
  left_join(site_effort, by = "Site") %>% 
  mutate(CPUE = BlackBass/TotalEffort)

Organize and export data for analysis

# Separate catch data, environmental, and site data for easier viewing
bass_rate <- site_catch %>% 
  filter(!is.na(CPUE)) %>% 
  select(Date, Site, CPUE, Region, Subregion, Year, Month, BlackBass)

env_data <- site_catch %>% 
  filter(!is.na(EndLat)) %>% 
  select(Date, Site, Region, Subregion, Year, Month, Tide, Temp, DO, Cond, 
         Turbidity, Emergent, Floating, LWD, SAV, Substrate, BankType, Comments)

site_data <- site_catch %>% 
  filter(!is.na(EndLat)) %>% 
  select(Date, Site, Region, Subregion, Segment, Year, Month, StartLat, StartLong,
         EndLat, EndLong)

# Save final data files I will use for analysis
bass_file <- paste0("Data/BassCatchRate_", format(Sys.Date(), "%d%m%Y"), ".xlsx")

write.xlsx(bass_rate, file = bass_file)   

env_file <- paste0("Data/EnvData_", format(Sys.Date(), "%d%m%Y"), ".xlsx")

write.xlsx(env_data, file = env_file)

site_file <- paste0("Data/SiteData_", format(Sys.Date(), "%d%m%Y"), ".xlsx")

write.xlsx(site_data, file = site_file)

To determine the best approach for a neighbors definition, distances were calculated between each site and the nearest neighbor distance was calculated and plotted. Four different distance thresholds were examined within the range of neighbor distances present (250, 500, 1000, and 2000 m). An appropriate threshold was determined to be the distance that encompassed at least one neighbor for each site (2,000 m) and a distance matrix was created. However, inverse-distance weighting was used with a power of 1 so that nearer sites have more weight in calculations than farther ones.


Load packages and data

# Load packages
library(spdep)
library(sf)
library(dplyr)
library(openxlsx)
library(units)
library(tidyverse)
library(patchwork)

# Read in prepared data files
bass_data <- read.xlsx("Data/BassCatchRate_29112026.xlsx", detectDates = TRUE)

site_data <- read.xlsx("Data/SiteData_29112026.xlsx", detectDates = TRUE)

Find the midpoint of each site to use as site coordinates

# Calculate midpoint of the middle segment for each site
site_midpoints <- site_data %>% distinct(Site, Segment, StartLat, StartLong,
    EndLat, EndLong) %>%
  arrange(Site, Segment) %>%
  group_by(Site) %>%
  filter(!is.na(EndLong)) %>% 
  mutate(number_segments = n(), middle_segment = ceiling(number_segments/2)) %>%
  filter(Segment == middle_segment) %>% 
  mutate(MidLat = (StartLat + EndLat)/2, MidLong = (StartLong + EndLong)/2) %>%
  ungroup()

# Fix duplicate site coordinates
site_midpoints$MidLong[670] <- site_midpoints$MidLong[670] - 0.0001   
site_midpoints$MidLong[665] <- site_midpoints$MidLong[665] - 0.0001

# Save site coordinates
write.csv(site_midpoints, "Data/Site_Midpoints.csv")

Create one dataframe so that rows match

# Combine CPUE and site coordinates
moran_data <- bass_data %>%
  inner_join(site_midpoints, by = "Site") %>%
  arrange(Site)

# Convert coordinates to spatial points 
sites_sf <- st_as_sf(moran_data, coords = c("MidLong", "MidLat"),crs = 4326)

# Project CRS: NAD83/UTM zone 10N, Transverse Mercator projection with a GRS 1980 ellipsoid, units in meters
sites_sf <- st_transform(sites_sf, 26910)

site_coords <- st_coordinates(sites_sf)

The Global Moran’s I (Bivand et al., 2009; Clif and Ord, 1981) was calculated to test whether black bass catch rates exhibit spatial autocorrelation across the study area. Parameters used and their justifications are listed below (Table 1). Statistical significance was evaluated to determine whether observed catch patterns differ significantly from a random distribution. A Moran’s scatterplot was created to show the relationship between the standardized catch rate and standardized lagged catch rate following the steps outlined by Brazil (2023).

Table 1. Global Moran’s I parameters used to assess autocorrelation of black bass catch rates in the study area.

Parameter Setting Explanation
Neighbor definition Fixed distance Sites within 2,000 m are neighbors
Distance threshold 2,000 m Maximum distance between neighboring sites
Weighting method Inverse distance Closer sites receive greater weights
Distance power 1 Weight decreases proportionally to inverse distance
Standardization style = “W” Weights for each site’s neighbors sum to 1
Test assumption Randomization Evaluates spatial randomness under the randomization null hypothesis
Alternative greater Tests specifically for positive spatial autocorrelation

The Local Moran’s I (Anselin, 1995) was then calculated for each year of sampling to identify high-high and low-low clusters, high-low and low-high spatial outliers, and non-significant patterns. For local Moran’s I tests, the same parameters were kept from the Global Moran’s I test (2,000 m distance threshold with inverse-distance weighting) and a Benjamini-Hochberg correction was applied to the p-values (Benjamani & Hochberg, 1995). LISA quadrant plots were created of each local Moran’s I results to visualize the relationship between black bass catch rates and the lag of catch rates by cluster type (Brazil, 2023). However, no due to a high level of isolated sites each year, few significant results were obtained. Therefore, the local Moran’s I was calculated for all years combined. The spatial clusters were then visualized geographically in QGIS (QGIS Development Team 2026). Heat maps were created for environmental variables recorded at each site, including water temperature, conductivity, turbidity, dissolved oxygen, substrate, bank type, submerged aquatic vegetation (SAV), emergent vegetation, large woody debris (LWD), and substrate to visually compare hot or cold spot overlap to black bass catch rate clusters.

Results

Catch and Effort


Summarize catch and effort per year

# find number of sites sampled each and effort
site_summary <- site_catch %>% group_by(Year) %>% 
  summarise(Sites_Sampled = n_distinct(StartLat), Effort_hrs = sum(TotalEffort)/3600, 
         Months_Sampled = paste(min(Month), "-", max(Month)), 
         Bass_Catch = paste (min(BlackBass), "-", max(BlackBass)), Mean_Catch = 
           mean(BlackBass), Median_Catch= median(BlackBass))

# Create table 
SS <- flextable(site_summary) %>% bold(part = "header")

Table 2. Summary of sample site numbers, effort and black bass catch per year.

SS

Year

Sites_Sampled

Effort_hrs

Months_Sampled

Bass_Catch

Mean_Catch

Median_Catch

2,021

93

9.033611

7 - 12

0 - 83

13.47312

11

2,022

224

33.319444

1 - 12

0 - 96

13.83111

9

2,023

247

41.690278

1 - 12

0 - 127

15.20800

10

2,024

264

45.004167

1 - 12

0 - 115

15.82022

12

2,025

294

51.883333

1 - 12

0 - 102

17.62838

12

2,026

183

33.830000

1 - 7

0 - 69

17.14208

14

Analyses

Find distances between sites

# Calculate distances between all sites
site_distances <- st_distance(sites_sf)

# Convert distances to a numeric matrix
site_distances <- units::drop_units(site_distances)

# Exclude distance from each site to itself
diag(site_distances) <- Inf

# Find nearest neighbor distance for each site
nearest_distance <- apply(site_distances, 1, min)

# Summarize nearest neighbor distances in meters and plot
summary(nearest_distance)
##      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
##    0.5549   93.5178  179.8121  247.2188  331.2693 1956.0231
hist(nearest_distance, breaks = 20, 
     main = "Nearest Neighbor Distances Between Sampling Sites", 
     xlab = "Distance (meters)")

Figure 1. Distances between sampling sites, calculated as nearest neigbor, breaks represent 20 meters.

Compare different distance thresholds

# Compare different distance thresholds
distances <- c(250, 500, 1000, 2000)

# Examine the number of neighbors at each distance
neighbor_summary <- data.frame(
  Distance_m = distances,
  Mean_Neighbors = sapply(distances, function(d) {
    nb <- dnearneigh(site_coords, 0, d)
    mean(card(nb))
  }),
  Min_Neighbors = sapply(distances, function(d) {
    nb <- dnearneigh(site_coords, 0, d)
    min(card(nb))
  })
)

Table 3. Distance thresholds examined to determine the best fit for the dataset based on the mean and minimum number of neighbors to each site.

# View results
neighbor_summary
Distance_m Mean_Neighbors Min_Neighbors
250 1.382489 0
500 3.431644 0
1000 8.296467 0
2000 20.715822 1

Global Moran’s I

The global Moran’s I indicated significant positive spatial autocorrelation in black bass catch CPUE across all sampling locations (I = 0.186, z = 11.984, p < 0.001), indicating that sites with similar catch rates tended to occur near one another. This suggests that black bass CPUE was not spatially randomly distributed across the study area.

Create a spatial weights matrix

# Identify neighboring sites within 2,000 meters
bass_nb <- dnearneigh(site_coords, d1 = 0, d2 = 2000)

# Turn site distances into a numeric matrix
distance_matrix <- as.matrix(site_distances)

# Create inverse-distance weights for neighboring sites with a power of 1
bass_glist <- lapply(seq_along(bass_nb), function(i) {
  neighbors <- bass_nb[[i]]
  
  if (length(neighbors) == 0) {
    numeric(0)
  } else {
    1/distance_matrix[i, neighbors]
  }
})

# Create spatial weights matrix
bass_listw <- nb2listw(bass_nb, glist = bass_glist, style = "W", zero.policy = TRUE)

Run global Moran's I

# Global Moran's I test
moran.test(moran_data$CPUE, listw = bass_listw, alternative = "greater", 
           zero.policy = TRUE)
## 
##  Moran I test under randomisation
## 
## data:  moran_data$CPUE  
## weights: bass_listw    
## 
## Moran I statistic standard deviate = 11.984, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1864165854     -0.0007686395      0.0002439546
# Create a Moran's Scatterplot
moran.plot(as.numeric(scale(moran_data$CPUE)), listw=bass_listw, 
           xlab="Standardized Catch Rate (CPUE; fish/s)", 
           ylab="Standardized Lagged Catch Rate",
           main=c("Moran Scatterplot for Bass Catch Rate", "in the Delta") )

Figure 2. Scatter plot of the standardized black bass catch rate (x-axis) and its standardized spatial lag, which is the weighted average of the catch rate at neighboring locations (y-axis). The solid line represents the regression line, showing a positive association. The dashed lines represent means of the variables. Diamond shapes show observations with high ifluence in the regression.

Local Moran’s I

The number of sampling sites ranged from 90 in 2021 to 296 in 2025. Using the 2,000-meter distance threshold, the mean number of neighboring sites ranged from 1.44 in 2021 to 4.61 in 2025. The number of sites without any neighbors within the threshold varied by year. In 2021, 28 (31.1%) sites had no neighbors, 25 (11.2%) in 2022, 12 (4.8%) in 2023, 12 (4.5%) in 2024, 13 (4.4%) in 2025, and 20 (11.3%) in 2026. Sites without any neighbors in the annual neighboring distance calculations were excluded from the local Moran’s I tests.


Run local Moran's I for each year

### 2021 Spatial Data and Weights
# Filter 2021 data
moran_2021 <- moran_data %>% filter(Year == 2021) %>% arrange(Site)

# Convert to spatial points
sites_2021 <- st_as_sf(moran_2021, coords = c("MidLong", "MidLat"), crs = 4326,
                       remove = FALSE)

# Project coordinates
sites_2021 <- st_transform(sites_2021, 26910)

# Extract coordinates
coords_2021 <- st_coordinates(sites_2021)

# Calculate distances between sites
distances_2021 <- st_distance(sites_2021)
distances_2021 <- units::drop_units(distances_2021)

# Identify neighbors within 2,000 meters
nb_2021 <- dnearneigh(coords_2021, 0, 2000)

# Identify sites that have at least one neighbor
keep_2021 <- card(nb_2021) > 0

# Remove sites with no neighbors
moran_2021 <- moran_2021[keep_2021,]

# Remove corresponding spatial features
sites_2021 <- sites_2021[keep_2021, ]

# Recreate coordinates
coords_2021 <- st_coordinates(sites_2021)

# Recreate neighbors using 2,000 meters
nb_2021 <- dnearneigh(coords_2021, d1 = 0, d2 = 2000)

# Calculate distances
distances_2021 <- st_distance(sites_2021)
distances_2021 <- units::drop_units(distances_2021)

# Create binary neighbor matrix
adj_2021 <- nb2mat(nb_2021, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2021 <- ifelse(adj_2021 == 1, 1/distances_2021, 0)

# Set diagonal to zero
diag(weights_2021) <- 0

# Create row-standardized spatial weights
listw_2021 <- mat2listw(weights_2021, style = "W", zero.policy = TRUE)



#### 2022 Spatial Data and Weights 
# Filter 2022 data
moran_2022 <- moran_data %>% filter(Year == 2022) %>% arrange(Site)

# Convert to spatial points
sites_2022 <- st_as_sf(moran_2022, coords = c("MidLong", "MidLat"), crs = 4326,
                       remove = FALSE)

# Project coordinates
sites_2022 <- st_transform(sites_2022, 26910)

# Extract coordinates
coords_2022 <- st_coordinates(sites_2022)

# Calculate distances between sites
distances_2022 <- st_distance(sites_2022)
distances_2022 <- units::drop_units(distances_2022)

# Identify neighbors within 2,000 meters
nb_2022 <- dnearneigh(coords_2022, 0, 2000)

# Identify sites that have at least one neighbor
keep_2022 <- card(nb_2022) > 0

# Remove sites with no neighbors
moran_2022 <- moran_2022[keep_2022,]

# Remove corresponding spatial features
sites_2022 <- sites_2022[keep_2022, ]

# Recreate coordinates
coords_2022 <- st_coordinates(sites_2022)

# Recreate neighbors using 2,000 meters
nb_2022 <- dnearneigh(coords_2022, d1 = 0, d2 = 2000)

# Calculate distances
distances_2022 <- st_distance(sites_2022)
distances_2022 <- units::drop_units(distances_2022)

# Create binary neighbor matrix
adj_2022 <- nb2mat(nb_2022, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2022 <- ifelse(adj_2022 == 1, 1/distances_2022, 0)

# Set diagonal to zero
diag(weights_2022) <- 0

# Create row-standardized spatial weights
listw_2022 <- mat2listw(weights_2022, style = "W", zero.policy = TRUE)



#### 2023 Spatial Data and Weights
# Filter 2023 data
moran_2023 <- moran_data %>% filter(Year == 2023) %>% arrange(Site)

# Convert to spatial points
sites_2023 <- st_as_sf(moran_2023, coords = c("MidLong", "MidLat"), crs = 4326, remove = FALSE)

# Project coordinates
sites_2023 <- st_transform(sites_2023, 26910)

# Extract coordinates
coords_2023 <- st_coordinates(sites_2023)

# Calculate distances between sites
distances_2023 <- st_distance(sites_2023)
distances_2023 <- units::drop_units(distances_2023)

# Identify neighbors within 2,000 meters
nb_2023 <- dnearneigh(coords_2023, 0, 2000)

# Identify sites that have at least one neighbor
keep_2023 <- card(nb_2023) > 0

# Remove sites with no neighbors
moran_2023 <- moran_2023[keep_2023,]

# Remove corresponding spatial features
sites_2023 <- sites_2023[keep_2023, ]

# Recreate coordinates
coords_2023 <- st_coordinates(sites_2023)

# Recreate neighbors using 2,000 meters
nb_2023 <- dnearneigh(coords_2023, d1 = 0, d2 = 2000)

# Calculate distances
distances_2023 <- st_distance(sites_2023)
distances_2023 <- units::drop_units(distances_2023)

# Create binary neighbor matrix
adj_2023 <- nb2mat(nb_2023, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2023 <- ifelse(adj_2023 == 1, 1/distances_2023, 0)

# Set diagonal to zero
diag(weights_2023) <- 0

# Create row-standardized spatial weights
listw_2023 <- mat2listw(weights_2023, style = "W", zero.policy = TRUE)



#### 2024 Spatial Data and Weights
# Filter 2024 data
moran_2024 <- moran_data %>% filter(Year == 2024) %>% arrange(Site)

# Convert to spatial points
sites_2024 <- st_as_sf(moran_2024, coords = c("MidLong", "MidLat"), crs = 4326,
                       remove = FALSE)

# Project coordinates
sites_2024 <- st_transform(sites_2024, 26910)

# Extract coordinates
coords_2024 <- st_coordinates(sites_2024)

# Calculate distances between sites
distances_2024 <- st_distance(sites_2024)
distances_2024 <- units::drop_units(distances_2024)

# Identify neighbors within 2,000 meters
nb_2024 <- dnearneigh(coords_2024, 0, 2000)

# Identify sites that have at least one neighbor
keep_2024 <- card(nb_2024) > 0

# Remove sites with no neighbors
moran_2024 <- moran_2024[keep_2024,]

# Remove corresponding spatial features
sites_2024 <- sites_2024[keep_2024, ]

# Recreate coordinates
coords_2024 <- st_coordinates(sites_2024)

# Recreate neighbors using 2,000 meters
nb_2024 <- dnearneigh(coords_2024, d1 = 0, d2 = 2000)

# Calculate distances
distances_2024 <- st_distance(sites_2024)
distances_2024 <- units::drop_units(distances_2024)

# Create binary neighbor matrix
adj_2024 <- nb2mat(nb_2024, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2024 <- ifelse(adj_2024 == 1, 1/distances_2024, 0)

# Set diagonal to zero
diag(weights_2024) <- 0

# Create row-standardized spatial weights
listw_2024 <- mat2listw(weights_2024, style = "W", zero.policy = TRUE)


#### 2025 Spatial Data and Weights
# Filter 2025 data
moran_2025 <- moran_data %>% filter(Year == 2025) %>% arrange(Site)

# Convert to spatial points
sites_2025 <- st_as_sf(moran_2025, coords = c("MidLong", "MidLat"), crs = 4326,
                       remove = FALSE)

# Project coordinates
sites_2025 <- st_transform(sites_2025, 26910)

# Extract coordinates
coords_2025 <- st_coordinates(sites_2025)

# Calculate distances between sites
distances_2025 <- st_distance(sites_2025)
distances_2025 <- units::drop_units(distances_2025)

# Identify neighbors within 2,000 meters
nb_2025 <- dnearneigh(coords_2025, 0, 2000)

# Identify sites that have at least one neighbor
keep_2025 <- card(nb_2025) > 0

# Remove sites with no neighbors
moran_2025 <- moran_2025[keep_2025,]

# Remove corresponding spatial features
sites_2025 <- sites_2025[keep_2025, ]

# Recreate coordinates
coords_2025 <- st_coordinates(sites_2025)

# Recreate neighbors using 2,000 meters
nb_2025 <- dnearneigh(coords_2025, d1 = 0, d2 = 2000)

# Calculate distances
distances_2025 <- st_distance(sites_2025)
distances_2025 <- units::drop_units(distances_2025)

# Create binary neighbor matrix
adj_2025 <- nb2mat(nb_2025, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2025 <- ifelse(adj_2025 == 1, 1/distances_2025, 0)

# Set diagonal to zero
diag(weights_2025) <- 0

# Create row-standardized spatial weights
listw_2025 <- mat2listw(weights_2025, style = "W", zero.policy = TRUE)


#### 2026 Spatial Data and Weights
# Filter 2026 data
moran_2026 <- moran_data %>% filter(Year == 2026) %>% arrange(Site)

# Convert to spatial points
sites_2026 <- st_as_sf(moran_2026, coords = c("MidLong", "MidLat"), crs = 4326,
                       remove = FALSE)

# Project coordinates
sites_2026 <- st_transform(sites_2026, 26910)

# Extract coordinates
coords_2026 <- st_coordinates(sites_2026)

# Calculate distances between sites
distances_2026 <- st_distance(sites_2026)
distances_2026 <- units::drop_units(distances_2026)

# Identify neighbors within 2,000 meters
nb_2026 <- dnearneigh(coords_2026, 0, 2000)

# Identify sites that have at least one neighbor
keep_2026 <- card(nb_2026) > 0

# Remove sites with no neighbors
moran_2026 <- moran_2026[keep_2026,]

# Remove corresponding spatial features
sites_2026 <- sites_2026[keep_2026, ]

# Recreate coordinates
coords_2026 <- st_coordinates(sites_2026)

# Recreate neighbors using 2,000 meters
nb_2026 <- dnearneigh(coords_2026, d1 = 0, d2 = 2000)

# Calculate distances
distances_2026 <- st_distance(sites_2026)
distances_2026 <- units::drop_units(distances_2026)

# Create binary neighbor matrix
adj_2026 <- nb2mat(nb_2026, style = "B", zero.policy = TRUE)

# Calculate inverse-distance weights
weights_2026 <- ifelse(adj_2026 == 1, 1/distances_2026, 0)

# Set diagonal to zero
diag(weights_2026) <- 0

# Create row-standardized spatial weights
listw_2026 <- mat2listw(weights_2026, style = "W", zero.policy = TRUE)

Run Local Moran's I for each year

# Set random number seed for reproducibility
set.seed(783701)

# Run permutation-based Local Moran's I
local_2021 <- localmoran_perm(moran_2021$CPUE, listw_2021, nsim = 9999, 
              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
              "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

local_2022 <- localmoran_perm(moran_2022$CPUE, listw_2022, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

local_2023 <- localmoran_perm(moran_2023$CPUE, listw_2023, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

local_2024 <- localmoran_perm(moran_2024$CPUE, listw_2024, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

local_2025 <- localmoran_perm(moran_2025$CPUE, listw_2025, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

local_2026 <- localmoran_perm(moran_2026$CPUE, listw_2026, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

Apply Benjamini-Hochburg adjustment to P-values

# Add Local Moran's I to dataset
moran_2021$Local_I <- local_2021[["local_i"]]
moran_2022$Local_I <- local_2022[["local_i"]]
moran_2023$Local_I <- local_2023[["local_i"]]
moran_2024$Local_I <- local_2024[["local_i"]]
moran_2025$Local_I <- local_2025[["local_i"]]
moran_2026$Local_I <- local_2026[["local_i"]]

# Extract permutation-based p-values
moran_2021$Local_P <- local_2021[["p_i_sim"]]
moran_2022$Local_P <- local_2022[["p_i_sim"]]
moran_2023$Local_P <- local_2023[["p_i_sim"]]
moran_2024$Local_P <- local_2024[["p_i_sim"]]
moran_2025$Local_P <- local_2025[["p_i_sim"]]
moran_2026$Local_P <- local_2026[["p_i_sim"]]

# Apply Benjamini-Hochberg adjustment
moran_2021$Local_P_Adj <- p.adjust(moran_2021$Local_P, method = "BH")
moran_2022$Local_P_Adj <- p.adjust(moran_2022$Local_P, method = "BH")
moran_2023$Local_P_Adj <- p.adjust(moran_2023$Local_P, method = "BH")
moran_2024$Local_P_Adj <- p.adjust(moran_2024$Local_P, method = "BH")
moran_2025$Local_P_Adj <- p.adjust(moran_2025$Local_P, method = "BH")
moran_2026$Local_P_Adj <- p.adjust(moran_2026$Local_P, method = "BH")

Create plots of annual local Moran's I results

# Create LISA quadrant Plots
moran_2021 <- moran_2021 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2021, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

moran_2022 <- moran_2022 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2022, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

moran_2023 <- moran_2023 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2023, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

moran_2024 <- moran_2024 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2024, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

moran_2025 <- moran_2025 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2025, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

moran_2026 <- moran_2026 %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(listw_2026, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

 
color_values <- c("High-High" = "red",
                  "High-Low" = "pink",
                  "Low-Low" = "blue",
                  "Low-High" = "lightblue",
                  "Not Significant" = "white")


LP1 <- ggplot(moran_2021, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "",
       y = "Lag of black bass CPUE (z-score)",
       title = "2021",
       fill = "Cluster type") + theme(legend.position = "none")

LP2 <- ggplot(moran_2022, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "", y="",
       title = "2022",
       fill = "Cluster type")  + theme(legend.position = "none")

LP3 <- ggplot(moran_2023, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "", y="",
       title = "2023",
       fill = "Cluster type")  + theme(legend.position = "none")

LP4 <- ggplot(moran_2024, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "", y="",
       title = "2024",
       fill = "Cluster type") + theme(legend.position = "none")

LP5 <- ggplot(moran_2025, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "Black bass CPUE (z-score)",
       y = "",
       title = "2025",
       fill = "Cluster type")

LP6 <- ggplot(moran_2026, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "", y="",
       title = "2026",
       fill = "Cluster type")  + theme(legend.position = "none")


# Combine plots 
((LP1 | LP2 | LP3) / (LP4 | LP5 | LP6)) + plot_layout(axis_titles = "collect") +
  plot_layout(guides = "collect")  

Figure 3.

Run local Moran's I on all years combined

# Run permutation-based Local Moran's I
local_all <- localmoran_perm(moran_data$CPUE, bass_listw, nsim = 9999, 
                              zero.policy = TRUE) %>%
  as_tibble() %>%
  set_names (c("local_i", "exp_i", "var_i", "z_i", "p_i",
               "p_i_sim", "pi_sim_folded", "skewness", "kurtosis"))

## Apply BH Adjustment
# Add Local Moran's I to dataset
moran_local <- moran_data %>%
  mutate(Local_I = local_all$local_i, Local_P = local_all$p_i_sim)

# Apply Benjamini-Hochberg adjustment
moran_local$Local_P_Adj <- p.adjust(moran_local$Local_P, method = "BH")

Plot results

# Create LISA quadrant Plots
moran_local <- moran_local %>%
  mutate(CPUE_Z =  as.numeric(scale(CPUE)), 
         CPUElag = lag.listw(bass_listw, CPUE_Z, zero.policy = TRUE),
         lisa_cluster = case_when(
           is.na(Local_P_Adj) | Local_P_Adj >= 0.05 ~ "Not Significant",
           CPUE_Z > 0 & CPUElag > 0 ~ "High-High",
           CPUE_Z < 0 & CPUElag < 0 ~ "Low-Low",
           CPUE_Z > 0 & CPUElag < 0 ~ "High-Low",
           CPUE_Z < 0 & CPUElag > 0 ~ "Low-High",
           TRUE ~ "Not Significant"))

ggplot(moran_local, aes(x = CPUE_Z,
                       y = CPUElag,
                       fill = lisa_cluster)) + 
  geom_point(color = "black", shape = 21, size = 2) + 
  theme_minimal() + 
  geom_hline(yintercept = 0, linetype = "dashed") + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  scale_fill_manual(values = color_values) + 
  labs(x = "", y= "",
       title = "Local Moran's I",
       fill = "Cluster type")

Figure 4.

hist(moran_local$Local_I,
     main = "Distribution of Local Moran's I (2021)",
     xlab = "Local Moran's I")

Figure 5.

# Count sites in each cluster category
cluster_types_local <- moran_local %>% group_by(lisa_cluster) %>% 
  summarise(Count = n())

Table 4.

tibble(cluster_types_local)  
lisa_cluster Count
High-High 14
High-Low 7
Low-High 4
Low-Low 130
Not Significant 1147

Reflection

A global Moran’s I test was not conducted for each year separately due to the probability of autocorrelation and the inability to determine if effect size is due to differences in sample sizes or weights between years.

References

Anselin, L. (1995) “Local indicators of spatial association.” Geographical Analysis 27:93–115.

Benjamini, Y. & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society: Series B (Methodological), 57(1):289–300.

Bivand R.S., Müller W., Reder M. (2009). “Power calculations for global and local Moran’s I.” Computational Statistics & Data Analysis 53:2859–2872.

Bivand R & Wong D (2018). “Comparing implementations of global and local indicators of spatial association.” TEST, 27(3):716–748.

Brazil, N. (2023). Lab 7: Spatial autocorrelation, CRD 230 - Spatial methods in community research. https://crd230.github.io/lab7.html

Cliff, A.D. & Ord, J.K. (1981). Spatial processes. Pion.

Interagency Ecological Program (IEP), Stagg, J., Speegle, J., Nanninga, A., Huber, E., Yun, S., Falcon, J., Mitchell, L., McKenzie, R., & Marcetti, D. (2026). Interagency Ecological Program: USFWS Delta Boat Electrofishing Survey, 2018-2026 ver 7. Environmental Data Initiative. https://doi.org/10.6073/pasta/1e762637531d8b20a4a3b25361b3ab1f (Accessed 2026-11-27).

Michel, C.J., Ammann, A.J., Lindley, S T., Sandstrom, P.T., Chapman, E.D, Thomas, M.J., Singer, G.P., Peter, K.A., & Bruce, M.R. (2015). Chinook salmon outmigration survival in wet and dry years in California’s Sacramento River. Can. J. Fish. Aquat. Sci. 72(11):1749–1759. https://doi.org/10.1139/cjfas20140528

Moyle, P.B. (2002). Inland Fishes of California (pp. 364–372). Univ of California Press.

OpenAI. (2026). ChatGPT [Large language model]. https://chatgpt.com/

Pebesma, E. (2018). Simple Features for R: Standardized Support for Spatial Vector Data. The R Journal, 10(1), 439–446. https://doi.org/10.32614/RJ-2018-009

QGIS Development Team. (2026). QGIS geographic information system. QGIS Association. https://www.qgis.org

R Core Team. (2025). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/