Fitting a Spatial Factor Multi-Species Occupancy Model

Data from: Yasuni

model
code
analysis
140 sites, 25 mammal species
Authors

German Forero

Robert Wallace

Galo Zapara-Rios

Emiliana Isasi-Catalá

Diego J. Lizcano

Published

August 16, 2025

Single-species occupancy models

Single-species occupancy models (MacKenzie et al., 2002) are widely used in ecology to estimate and predict the spatial distribution of a species from data collected in presence–absence repeated surveys. The popularity of these models stems from their ability to estimate the effects of environmental or management covariates on species occurrences, while accounting for false-negative errors in detection, which are common in surveys of natural populations.

Multi-species occupancy models

Multi-species occupancy models for estimating the effects of environmental covariates on several species occurrences while accounting for imperfect detection were build on the principle of the Single-species occupancy model, and developed more than 20 years ago.

Multi-species occupancy models are a powerful tool for combining information from multiple species to estimate both individual and community-level responses to management and environmental variables.

Objective

We want to asses the effect of protected areas on the occupancy of the species. We hypothesize that several mammal species have benefited of the conservation actions provided by protected areas, so we expect a decreases in occupancy from the interior of the protected area to the exterior as a function of the distance to the protected area border.

To account for several ecological factors we also tested and included elevation and forest integrity index as occupancy covariates.

We used the newly developed R package spOccupancy as approach to modelling the probability of occurrence of each species as a function of fixed effects of measured environmental covariates and random effects designed to account for unobserved sources of spatial dependence (spatial autocorrelation).

Code
library(grateful) # Facilitate Citation of R Packages
library(readxl) # Read Excel Files
library(DT) # A Wrapper of the JavaScript Library 'DataTables'
library(sf) # Simple Features for R
library(mapview) # Interactive Viewing of Spatial Data in R
library(maps) # Draw Geographical Maps
library(tmap) # Thematic Maps
library(terra) # Spatial Data Analysis
library(elevatr) # Access Elevation Data from Various APIs

# library(rjags) # Bayesian Graphical Models using MCMC 
library(bayesplot) # Plotting for Bayesian Models # Plotting for Bayesian Models
library(tictoc) # Functions for Timing R Scripts, as Well as Implementations of "Stack" and "StackList" Structures 
library(MCMCvis) # Tools to Visualize, Manipulate, and Summarize MCMC Output
library(coda) # Output Analysis and Diagnostics for MCMC
library(beepr) # Easily Play Notification Sounds on any Platform 
library(snowfall) # Easier Cluster Computing (Based on 'snow')

#library(ggmcmc)
library(camtrapR) # Camera Trap Data Management and Preparation 
library(spOccupancy) # Single-Species, Multi-Species, and Integrated Spatial Occupancy
library(tidyverse) # Easily Install and Load the 'Tidyverse'

Fitting a Multi-Species Spatial Occupancy Model

We use a more computationally efficient approach for fitting spatial multi-species occupancy models. This alternative approach is called a “spatial factor multi-species occupancy model”, and is described in depth in Doser, Finley, and Banerjee (2023). This newer approach also accounts for residual species correlations (i.e., it is a joint species distribution model with imperfect detection). The simulation results from Doser, Finley, and Banerjee (2023) show that this new alternative approach outperforms, or performs equally to spMsPGOcc(), while being substantially faster.

The Latent factor multi-species occupancy model is described in detail here

Data from Plantas Medicinales Putumayo

Here we use the table: - COL-18-Putumayo2023

Code
source("C:/CodigoR/WCS-CameraTrap/R/organiza_datos_v3.R")

AP_PlantasMed <- read_sf("C:/CodigoR/Occu_APs/shp/PlantasMedicinales/WDPA_WDOECM_May2025_Public_555511938_shp-polygons.shp")

### Ecu 17, Ecu 18, ECU 20, Ecu 22  

# load data and make array_locID column
Col_18 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Colombia/COL-018-Putumayo2023_WCS_WI.xlsx") |> mutate(array_locID=paste("Col_18", locationID, sep="_"))


# get sites
Col_18_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Colombia/COL-018-Putumayo2023_WCS_WI.xlsx")



# get elevation map
elevation_18 <- rast(get_elev_raster(Col_18_sites, z = 10)) #z =1-14
# bb <-  st_as_sfc(st_bbox(elevation_17)) # make bounding box 




# extract covs using points and add to _sites
covs_Col_18_sites <- cbind(Col_18_sites, terra::extract(elevation_18, Col_18_sites))
# covs_Col_17_sites <- cbind(Col_17_sites, terra::extract(elevation_17, Col_17_sites))


# get which are in and out
covs_Col_18_sites$in_AP = st_intersects(covs_Col_18_sites, AP_PlantasMed, sparse = FALSE)
# covs_Col_17_sites$in_AP = st_intersects(covs_Col_17_sites, AP_Yasuni, sparse = FALSE)




# make a map
mapview (elevation_18, alpha=0.5) + 
  mapview (AP_PlantasMed, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (covs_Col_18_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) 
  # mapview (covs_Col_17_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) +

Data fom Bajo Madidi and Heath

Here we use the tables: - BOL-008a - BOL-008b - BOL14a - BOL14b

Code
source("C:/CodigoR/WCS-CameraTrap/R/organiza_datos_v3.R")

Area_Madidi <- read_sf("C:/CodigoR/Occu_APs/shp/Area_Madidi/WDPA_WDOECM_Jul2025_Public_303894_shp-polygons.shp")

Madidi_NP <- read_sf("C:/CodigoR/Occu_APs/shp/Madidi_NP/WDPA_WDOECM_Jul2025_Public_98183_shp-polygons.shp")
#AP_Tahuayo <- read_sf("C:/CodigoR/Occu_APs/shp/Tahuayo/WDPA_WDOECM_Jun2025_Public_555555621_shp-polygons.shp")

# load data and make array_locID column
#Bol_Pacaya <- read_excel("F:/WCS-CameraTrap/data/BDcorregidas/Peru/PER-003_BD_ACRCTT_T0.xlsx", sheet = "Image")


Bol_Madidi_1 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Bolivia/Guido/BOL-008a.xlsx") |> mutate(Point.x=as.character(paste("M1",Point.x, sep = "-"))) |> mutate(Point.y=as.character(paste("M1",Point.y, sep = "-")))

Bol_Madidi_2 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Bolivia/Guido/BOL-008b.xlsx") |> mutate(Point.x=as.character(paste("M2",Point.x, sep = "-"))) |> mutate(Point.y=as.character(paste("M2",Point.y, sep = "-")))

Bol_Madidi_3 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Bolivia/Guido/BOL-014a.xlsx")|> mutate(Point.x=as.character(paste("M3",Point.x, sep = "-"))) |> mutate(Point.y=as.character(paste("M3",Point.y, sep = "-")))

Bol_Madidi_4 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Bolivia/Guido/BOL-014b.xlsx")|> mutate(Point.x=as.character(paste("M4",Point.x, sep = "-"))) |> mutate(Point.y=as.character(paste("M1",Point.y, sep = "-")))




# get sites
Bol_Madidi_sites1 <-  Bol_Madidi_1 |> 
   dplyr::bind_rows(Bol_Madidi_2) |> 
   dplyr::bind_rows(Bol_Madidi_3) |> 
   dplyr::bind_rows(Bol_Madidi_4) |> 
  select("Latitude", "Longitude", "Point.x" 
) |> dplyr::distinct( )  

Bol_Madidi_sites <- sf::st_as_sf(Bol_Madidi_sites1, coords = c("Longitude","Latitude"))
st_crs(Bol_Madidi_sites) <- 4326


# get elevation map
elevation_17 <- rast(get_elev_raster(Bol_Madidi_sites, z = 9)) #z =1-14
# bb <-  st_as_sfc(st_bbox(elevation_17)) # make bounding box 



# extract covs using points and add to _sites
covs_Bol_Madidi_sites <- cbind(Bol_Madidi_sites, terra::extract(elevation_17, Bol_Madidi_sites))
# covs_Ecu_17_sites <- cbind(Ecu_17_sites, terra::extract(elevation_17, Ecu_17_sites))


# get which are in and out
covs_Bol_Madidi_sites$in_AP = st_intersects(covs_Bol_Madidi_sites, Madidi_NP, sparse = FALSE)
# covs_Ecu_17_sites$in_AP = st_intersects(covs_Ecu_17_sites, AP_Machalilla, sparse = FALSE)


# make a map
mapview (elevation_17, alpha=0.7) + 
  mapview (Madidi_NP, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (Area_Madidi, color = "yellow", col.regions = "yellow", alpha = 0.5) +
  #mapview (AP_Tahuayo, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (covs_Bol_Madidi_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) 

Tamshiyacu Tahuayo data

Here we use the tables: - PER-003_BD_ACRCTT_T0.xlsx - PER-002_BD_ACRTT-PILOTO.xlsx

Code
source("C:/CodigoR/WCS-CameraTrap/R/organiza_datos_v3.R")

AP_Pacaya <- read_sf("C:/CodigoR/Occu_APs/shp/PacayaSamiria/WDPA_WDOECM_Jun2025_Public_249_shp-polygons.shp")

AP_Tahuayo <- read_sf("C:/CodigoR/Occu_APs/shp/Tahuayo/WDPA_WDOECM_Jun2025_Public_555555621_shp-polygons.shp")

# load data and make array_locID column
Per_Tahuayo_piloto <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Peru/PER-002_BD_ACRTT-PILOTO.xlsx")



Per_Tahuayo <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Peru/PER-003_BD_ACRCTT_T0.xlsx")

 
FLII2016 <- rast("C:/CodigoR/WCS_2024/FLI/raster/FLII_final/FLII_2016.tif")

# get sites
# Per_Pacaya_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Peru/PER-003_BD_ACRCTT_T0.xlsx")

# get sites
Per_Tahuayo_sites1 <- Per_Tahuayo |> select("Latitude",
                                    "Longitude",
                                    "Camera_Id" 
                                    ) |> dplyr::distinct( )  

Per_Tahuayo_sites <- sf::st_as_sf(Per_Tahuayo_sites1, coords = c("Longitude","Latitude"))
st_crs(Per_Tahuayo_sites) <- 4326



# get Pacaya sites
Per_Tahuayo_piloto_sites1 <- Per_Tahuayo_piloto |> select("Latitude",
                                    "Longitude",
                                    "Camera_Id" 
                                    ) |> dplyr::distinct( )  

Per_Tahuayo_piloto_sites <- sf::st_as_sf(Per_Tahuayo_piloto_sites1, coords = c("Longitude","Latitude"))
st_crs(Per_Tahuayo_piloto_sites) <- 4326




# get elevation map
elevation_PE <- rast(get_elev_raster(Per_Tahuayo_sites, z = 10)) #z =1-14
# bb <-  st_as_sfc(st_bbox(elevation_17)) # make bounding box 





# extract covs using points and add to _sites
covs_Per_Tahuayo_sites <- cbind(Per_Tahuayo_sites,
                                terra::extract(elevation_PE,
                                               Per_Tahuayo_sites)
                                )

# extract covs using points and add to _sites
covs_Per_Tahuayo_piloto_sites <- cbind(Per_Tahuayo_piloto_sites, terra::extract(elevation_PE, Per_Tahuayo_piloto_sites))



# get which are in and out
covs_Per_Tahuayo_sites$in_AP = st_intersects(covs_Per_Tahuayo_sites, AP_Tahuayo, sparse = FALSE)

covs_Per_Tahuayo_piloto_sites$in_AP = st_intersects(covs_Per_Tahuayo_piloto_sites, AP_Tahuayo, sparse = FALSE)




# make a map
mapview (elevation_PE, alpha=0.5) + 
  mapview (AP_Pacaya, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (AP_Tahuayo, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (covs_Per_Tahuayo_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) +   
  mapview (covs_Per_Tahuayo_piloto_sites, 
           zcol = "in_AP", 
           col.regions =c("blue"), 
           burst = TRUE) 

Yasuni data

Here we use the tables Ecu-13, Ecu-17, Ecu-18 y Ecu-20

Code
source("C:/CodigoR/WCS-CameraTrap/R/organiza_datos_v3.R")

AP_Yasuni <- read_sf("C:/CodigoR/Occu_APs/shp/Yasuni/WDPA_WDOECM_May2025_Public_186_shp-polygons.shp")

### Ecu 17, Ecu 18, ECU 20, Ecu 22  

# load data and make array_locID column
Ecu_13 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-013.xlsx") |> mutate(array_locID=paste("Ecu_13", locationID, sep="_"))
28 cameras in Cameras. 
 28 cameras in Deployment. 
 28 deployments in Deployment. 
 28 points in Deployment. 
 28 cameras in Images. 
 28 points in Images. 
[1] "dates ok"
year: 2015 
 Jaguar_Design: no 
Code
Ecu_17 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-017.xlsx") |> mutate(array_locID=paste("Ecu_17", locationID, sep="_"))
30 cameras in Cameras. 
 30 cameras in Deployment. 
 30 deployments in Deployment. 
 30 points in Deployment. 
 30 cameras in Images. 
 30 points in Images. 
[1] "dates ok"
year: 2015 
 Jaguar_Design: no 
Code
Ecu_18 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-018.xlsx")|> mutate(array_locID=paste("Ecu_18", locationID, sep="_"))
30 cameras in Cameras. 
 30 cameras in Deployment. 
 30 deployments in Deployment. 
 30 points in Deployment. 
 30 cameras in Images. 
 30 points in Images. 
[1] "dates ok"
year: 2016 
 Jaguar_Design: no 
Code
Ecu_20 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-020_Fix.xlsx")|> mutate(array_locID=paste("Ecu_20", locationID, sep="_"))
30 cameras in Cameras. 
 25 cameras in Deployment. 
 25 deployments in Deployment. 
 25 points in Deployment. 
 25 cameras in Images. 
 25 points in Images. 
[1] "dates ok"
year: 2018 
 Jaguar_Design: no 
Code
# Ecu_21 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-021.xlsx") |> mutate(array_locID=paste("Ecu_14", locationID, sep="_"))
Ecu_22 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-022.xlsx")|> mutate(array_locID=paste("Ecu_22", locationID, sep="_"))
30 cameras in Cameras. 
 30 cameras in Deployment. 
 30 deployments in Deployment. 
 30 points in Deployment. 
 30 cameras in Images. 
 30 points in Images. 
[1] "dates ok"
year: 2018 
 Jaguar_Design: no 
Code
# get sites
Ecu_13_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-013.xlsx")
Ecu_17_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-017.xlsx")
Ecu_18_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-018.xlsx")
Ecu_20_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-020_Fix.xlsx")
# Ecu_21_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-021.xlsx")
Ecu_22_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-022.xlsx")


FLII2016 <- rast("C:/CodigoR/WCS_2024/FLI/raster/FLII_final/FLII_2016.tif")

# get elevation map
elevation_EC <- rast(get_elev_raster(Ecu_17_sites, z = 7)) #z =1-14
bb <-  st_as_sfc(st_bbox(elevation_EC)) # make bounding box 




# extract covs using points and add to _sites
covs_Ecu_13_sites <- cbind(Ecu_13_sites, terra::extract(elevation_EC, Ecu_13_sites))
covs_Ecu_17_sites <- cbind(Ecu_17_sites, terra::extract(elevation_EC, Ecu_17_sites))
covs_Ecu_18_sites <- cbind(Ecu_18_sites, terra::extract(elevation_EC, Ecu_18_sites))
covs_Ecu_20_sites <- cbind(Ecu_20_sites, terra::extract(elevation_EC, Ecu_20_sites))
#covs_Ecu_21_sites <- cbind(Ecu_21_sites, terra::extract(elevation_17, Ecu_21_sites))
covs_Ecu_22_sites <- cbind(Ecu_22_sites, terra::extract(elevation_EC, Ecu_22_sites))

# get which are in and out
covs_Ecu_13_sites$in_AP = st_intersects(covs_Ecu_13_sites, AP_Yasuni, sparse = FALSE)
covs_Ecu_17_sites$in_AP = st_intersects(covs_Ecu_17_sites, AP_Yasuni, sparse = FALSE)
covs_Ecu_18_sites$in_AP = st_intersects(covs_Ecu_18_sites, AP_Yasuni, sparse = FALSE)
covs_Ecu_20_sites$in_AP = st_intersects(covs_Ecu_20_sites, AP_Yasuni, sparse = FALSE)
#covs_Ecu_21_sites$in_AP = st_intersects(covs_Ecu_21_sites, AP_Yasuni, sparse = FALSE)
covs_Ecu_22_sites$in_AP = st_intersects(covs_Ecu_22_sites, AP_Yasuni, sparse = FALSE)

# covs_Ecu_16_sites$in_AP = st_intersects(covs_Ecu_16_sites, AP_Llanganates, sparse = FALSE)



# make a map
mapview (elevation_EC, alpha=0.5) + 
  mapview (AP_Yasuni, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (covs_Ecu_13_sites, zcol = "in_AP", col.regions =c("red"), burst = TRUE) +
  mapview (covs_Ecu_17_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) +
  mapview (covs_Ecu_18_sites, zcol = "in_AP", col.regions =c("red"), burst = TRUE) +
  mapview (covs_Ecu_20_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) +
#  mapview (covs_Ecu_21_sites, zcol = "in_AP", col.regions =c("red"), burst = TRUE) +
  mapview (covs_Ecu_22_sites, zcol = "in_AP", burst = TRUE, col.regions = c("red") ) #+
Code
  # mapview (covs_Ecu_16_sites, zcol = "in_AP", burst = TRUE, col.regions =c("red","blue")) 

Llanganates data

Here we use the tables Ecu-14, Ecu-15 y Ecu-16.

Code
AP_Llanganates <- read_sf("C:/CodigoR/Occu_APs/shp/Llanganates/WDPA_WDOECM_May2025_Public_97512_shp-polygons.shp")

### Ecu 14, Ecu 15  y Ecu 16

# load data and make array_locID column
Ecu_14 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-014.xlsx") |> mutate(array_locID=paste("Ecu_14", locationID, sep="_"))
Ecu_15 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-015.xlsx")|> mutate(array_locID=paste("Ecu_15", locationID, sep="_"))
Ecu_16 <- loadproject("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-016.xlsx")|> mutate(array_locID=paste("Ecu_16", locationID, sep="_"))



# get sites
Ecu_14_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-014.xlsx")
Ecu_15_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-015.xlsx")
Ecu_16_sites <- get.sites("F:/WCS-CameraTrap/data/BDcorregidas/Ecuador/ECU-016.xlsx")




# get elevation map
elevation_14 <- rast(get_elev_raster(Ecu_14_sites, z = 7)) #z =1-14
bb <-  st_as_sfc(st_bbox(elevation_14)) # make bounding box 




# extract covs using points and add to _sites
covs_Ecu_14_sites <- cbind(Ecu_14_sites, terra::extract(elevation_14, Ecu_14_sites))

covs_Ecu_15_sites <- cbind(Ecu_15_sites, terra::extract(elevation_14, Ecu_15_sites))

covs_Ecu_16_sites <- cbind(Ecu_16_sites, terra::extract(elevation_14, Ecu_16_sites))

# get which are in and out
covs_Ecu_14_sites$in_AP = st_intersects(covs_Ecu_14_sites, AP_Llanganates, sparse = FALSE)

covs_Ecu_15_sites$in_AP = st_intersects(covs_Ecu_15_sites, AP_Llanganates, sparse = FALSE)

covs_Ecu_16_sites$in_AP = st_intersects(covs_Ecu_16_sites, AP_Llanganates, sparse = FALSE)



# make a map
mapview (elevation_14, alpha=0.7) + 
  mapview (AP_Llanganates, color = "green", col.regions = "green", alpha = 0.5) +
  mapview (covs_Ecu_14_sites, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE) +
  mapview (covs_Ecu_15_sites, zcol = "in_AP", burst = TRUE, col.regions = c("blue") )+
  mapview (covs_Ecu_16_sites, zcol = "in_AP", burst = TRUE, col.regions =c("red","blue")) 

Pacoche 2014 data

Here we use the tables Pacoche_DL_CT-RVP-2014

Camera trap operation data and detection history

Code
# Join 3 tables
# fix count in ECU 13, 17, 22,
Ecu_13$Count <- as.character(Ecu_13$Count)
Ecu_17$Count <- as.character(Ecu_17$Count)
Ecu_22$Count <- as.character(Ecu_22$Count)

Ecu_full <- Ecu_13 |> full_join(Ecu_17) |> 
                      full_join(Ecu_18) |> 
                      full_join(Ecu_20) |> 
#                      full_join(Ecu_21) |> 
                      full_join(Ecu_22)

###### Bolivia

# Bol_full <- Bol_Madidi_1  |> 
#    full_join(Bol_Madidi_2) |> 
#    full_join(Bol_Madidi_3) |> 
#    full_join(Bol_Madidi_4) 
# # change camera Id by point. two cameras in one
# Bol_full <- Bol_full |> mutate(Camera_Id=Point.x)


# # Ecu_18$Count <- as.numeric(Ecu_18$Count)
# Per_Tahuayo_piloto$Longitude <- as.numeric(Per_Tahuayo_piloto$Longitude)
# Per_Tahuayo_piloto$Latitude <- as.numeric(Per_Tahuayo_piloto$Latitude)
# 

# Per_full <- Per_Tahuayo|> 
#   full_join(Per_Tahuayo_piloto) #|> 
#                       # full_join(Ecu_18) |> 
#                       # full_join(Ecu_20) |> 
#                       # full_join(Ecu_21) |> 
#                       # full_join(Ecu_22)

# rename camera id
# Per_full$camid <- Per_full$`Camera_Id`

Ecu_full$Count <- as.numeric(Ecu_full$Count)
# Per_full$Count <- as.numeric(Per_full$Count)


#################### Ecuador Llanganates

# Join 3 tables
# Ecu_Llanganates <- Ecu_14 |> full_join(Ecu_15) |> full_join(Ecu_16)


# make columns equal to 46
Ecu_full <- Ecu_full[,-47]
# Col_18 <- Col_18[,-47]
# Ecu_Llanganates <- Ecu_Llanganates[,-c(50,49,48,47)]

##################################
data_full <- Ecu_full# rbind(Ecu_full, 
                   # Per_full,
                   # Bol_full,
                   # Col_18,
                   # Ecu_Llanganates)


# fix date format
# 
# Formatting a Date object
data_full$start_date <- as.Date(data_full$"start_date", "%Y/%m/%d")
data_full$start_date <- format(data_full$start_date, "%Y-%m-%d")

data_full$end_date <- as.Date(data_full$"end_date", "%Y/%m/%d")
data_full$end_date <- format(data_full$end_date, "%Y-%m-%d")

data_full$eventDate <- as.Date(data_full$"Date_Time_Captured", "%Y/%m/%d")
data_full$eventDate <- format(data_full$eventDate, "%Y-%m-%d")

# Per_full$eventDateTime <- ymd_hms(paste(Per_full$"photo_date", Per_full$"photo_time", sep=" "))
data_full$eventDateTime <- ymd_hms(data_full$"Date_Time_Captured")

###############################
# remove duplicated cameras
################################
ind1 <- which(data_full$Camera_Id=="ECU-020-C0027")
ind2 <- which(data_full$Camera_Id=="ECU-020-C0006")
ind3 <- which(data_full$Camera_Id=="ECU-022-C0076")
data_full <- data_full[-ind1,]
data_full <- data_full[-ind2,]
data_full <- data_full[-ind3,]

# filter 2021 and make uniques
CToperation  <- data_full |> dplyr::group_by(Camera_Id) |> #(array_locID) |> 
                           mutate(minStart=start_date, maxEnd=end_date) |> distinct(Longitude, Latitude, minStart, maxEnd) |> dplyr::ungroup()
# remove one duplicated
# View(CToperation)
# CToperation <- CToperation[-15,]

# M3-19: M3-21: M4-10: M4-12: M4-18:  From Madidi
# CToperation <- CToperation[-c(379, 373, 365, 362, 357),]

# CToperation[231,3] <- "-4.482831" #Latitude
CToperation[93,3] <- -0.5548211 #Latitude
CToperation[93,2] <- -76.48333

# duplicated in llanganates
# CToperation <- CToperation[-464,] 

### Check duplicated
# View(as.data.frame(sort(table(CToperation$Latitude))))
# View(as.data.frame(sort(table(CToperation$Longitude))))
# View(as.data.frame(table(CToperation$Camera_Id)))

# CToperation <- CToperation[-c(90,94),]
# Latitude -4.48283
# Latitude -0.554820969700813
# Longitude -76.4833290316164

# Generamos la matríz de operación de las cámaras

camop <- cameraOperation(CTtable= CToperation, # Tabla de operación
                         stationCol= "Camera_Id", # Columna que define la estación
                         setupCol= "minStart", #Columna fecha de colocación
                         retrievalCol= "maxEnd", #Columna fecha de retiro
                         #hasProblems= T, # Hubo fallos de cámaras
                         dateFormat= "%Y-%m-%d")#, #, # Formato de las fechas
                         #cameraCol="Camera_Id")
                         # sessionCol= "Year")

# Generar las historias de detección ---------------------------------------
## remove plroblem species

# Per_full$scientificName <- paste(Per_full$genus, Per_full$species, sep=" ")

#### remove NAs and setups
# ind <- which(is.na(data_full$scientificName))
# data_full <- data_full[-ind,]
# ind <- which(Per_full$scientificName=="NA NA")
# Per_full <- Per_full[-ind,]

# ind <- which(Per_full$scientificName=="Set up")
# Per_full <- Per_full[-ind,]
# 
# ind <- which(Per_full$scientificName=="Blank")
# Per_full <- Per_full[-ind,]
# 
# ind <- which(Per_full$scientificName=="Unidentifiable")
# Per_full <- Per_full[-ind,]


DetHist_list <- lapply(unique(data_full$scientificName), FUN = function(x) {
  detectionHistory(
    recordTable         = data_full, # abla de registros
    camOp                = camop, # Matriz de operación de cámaras
    stationCol           = "Camera_Id",
    speciesCol           = "scientificName",
    recordDateTimeCol    = "eventDateTime",
    recordDateTimeFormat  = "%Y-%m-%d %H:%M:%S",
    species              = x,     # la función reemplaza x por cada una de las especies
    occasionLength       = 7, # Colapso de las historias a 10 ías
    day1                 = "station", # "survey" a specific date, "station", #inicie en la fecha de cada survey
    datesAsOccasionNames = FALSE,
    includeEffort        = TRUE,
    scaleEffort          = FALSE,
    #unmarkedMultFrameInput=TRUE
    timeZone             = "America/Bogota" 
    )
  }
)

# names
names(DetHist_list) <- unique(data_full$scientificName)

# Finalmente creamos una lista nueva donde estén solo las historias de detección
ylist <- lapply(DetHist_list, FUN = function(x) x$detection_history)
# otra lista con effort scaled
efort <- lapply(DetHist_list, FUN = function(x) x$effort)

# number of observetions per sp, collapsed to 7 days
# lapply(ylist, sum, na.rm = TRUE)

Arrange spatial covariates

The standard EPSG code for a Lambert Azimuthal Equal-Area projection for South America is EPSG:10603 (WGS 84 / GLANCE South America). This projection is specifically designed for the continent and has its center located around the central meridian for the region. The units are meters.

FLII scores range from 0 (lowest integrity) to 10 (highest). Grantham discretized this range to define three broad illustrative categories: low (≤6.0); medium (>6.0 and <9.6); and high integrity (≥9.6).

Code
# #transform coord data to Lambert Azimuthal Equal-Area
# AP_Tahuayo_UTM <- st_transform(AP_Tahuayo, "EPSG:10603")
# # Convert to LINESTRING
# AP_Tahuayo_UTM_line <- st_cast(AP_Tahuayo_UTM,"MULTILINESTRING")# "LINESTRING")
#transform Yasuni to Lambert Azimuthal Equal-Area
AP_Yasuni_UTM <- st_transform(AP_Yasuni, "EPSG:10603")
# Convert to LINESTRING
AP_Yasuni_UTM_line <- st_cast(AP_Yasuni_UTM, "MULTILINESTRING")

# #transform Yasuni to Lambert Azimuthal Equal-Area
# AP_Madidi_UTM <- st_transform(Madidi_NP, "EPSG:10603")
# # Convert to LINESTRING
# AP_Madidi_UTM_line <- st_cast(AP_Madidi_UTM, "MULTILINESTRING")
# 
# # Plantas
# AP_PlantasMed_UTM <- st_transform(AP_PlantasMed, "EPSG:10603")
# 
# #Llanganates
# AP_Llanganates_UTM <- st_transform(AP_Llanganates, "EPSG:10603")


############## sf AP Union 
AP_merged_sf_UTM <- AP_Yasuni_UTM# st_union(
                             # AP_Yasuni_UTM,
                             # AP_Tahuayo_UTM,
                             # AP_Madidi_UTM,
                             # AP_PlantasMed_UTM,
                             # AP_Llanganates_UTM
                             # )

AP_merged_line <- st_cast(AP_merged_sf_UTM, to="MULTILINESTRING")


# make sf() from data table
data_full_sf <- CToperation |> 
    st_as_sf(coords = c("Longitude", "Latitude"), 
              crs = 4326)

# get the elevation point from AWS
elev_data <- elevatr::get_elev_point(locations = data_full_sf, src = "aws")
Mosaicing & Projecting
Note: Elevation units are in meters
Code
# extract elev and paste to table
data_full_sf$elev <- elev_data$elevation
str(data_full_sf$elev)
 num [1:141] 448 380 577 490 522 404 522 543 456 496 ...
Code
# extract in AP
data_full_sf$in_AP = as.factor(st_intersects(data_full_sf, AP_Yasuni, sparse = FALSE))

in_AP <- as.numeric((st_drop_geometry(data_full_sf$in_AP)))

# extract FLII
data_full_sf$FLII <- terra::extract(FLII2016, data_full_sf)[,2]
str(data_full_sf$FLII)
 num [1:141] 9.57 9.65 9.69 9.66 9.92 ...
Code
# Replace all NAs with min flii in a numeric column
data_full_sf$FLII[is.na(data_full_sf$FLII)] <- min(data_full_sf$FLII, na.rm = TRUE)

# mapview(full_sites_14_15_16_sf, zcol = "in_AP", burst = TRUE)

# Transform coord to Lambert Azimuthal Equal-Area
data_full_sf_UTM <- st_transform(data_full_sf, "EPSG:10603")


coords <- st_coordinates(data_full_sf_UTM)
#str(coords)

#### fix duplicated coord
# -1840583.53296873  en x
# -1842515.36969736  en x
# 1547741.44311964  en y
# 1541202.24796904 en y

# which(coords[,1]=="-1840583.53296873")
# which(coords[,1]=="-1842515.36969736")
which(coords[,1]=="-1842515.4768445")
[1] 93
Code
# which(coords[,2]=="1547741.44311964")
# which(coords[,2]=="1541202.24796904")
which(coords[,2]=="1541202.22737502")
[1] 93
Code
# make Ecu_14_15_16 an sf object
#    cam_sf <- st_as_sf(Ecu_14_15_16, coords = c("lon","lat"))   #crs="EPSG:4326")
    #--- set CRS ---#
#    st_crs(cam_sf) <- 4326




# Calculate the distance
#multiplic <- full_sites_14_15_16_sf_UTM |> mutate(multiplic= as.numeric(in_AP)) 
multiplic=ifelse(data_full_sf_UTM$in_AP=="TRUE",-1,1)
data_full_sf_UTM$border_dist <- as.numeric(st_distance(data_full_sf_UTM, AP_Yasuni_UTM_line) * multiplic )
# print(border_dist)

# convert true false to inside 1, outside 0
data_full_sf_UTM <- data_full_sf_UTM |>
  mutate(in_AP = case_when(
    str_detect(in_AP, "TRUE") ~ 1, # "inside_AP",
    str_detect(in_AP, "FALSE") ~ 0 #"outside_AP"
  )) |> mutate(in_AP=as.factor(in_AP))


hist(data_full_sf_UTM$border_dist)

Code
hist(data_full_sf_UTM$elev)

Prepare the model

TipData in a 3D array

The data must be placed in a three-dimensional array with dimensions corresponding to species, sites, and replicates in that order.

The function sfMsPGOcc

Fits multi-species spatial occupancy models with species correlations (i.e., a spatially-explicit joint species distribution model with imperfect detection). We use Polya-Gamma latent variables and a spatial factor modeling approach. Currently, models are implemented using a Nearest Neighbor Gaussian Process.

Code
# Detection-nondetection data ---------
# Species of interest, can select individually
# curr.sp <- sort(unique(Ecu_14_15_16$.id))# c('BAWW', 'BLJA', 'GCFL')
# sort(names(DetHist_list))
selected.sp <-  c(
"Atelocynus microtis" ,
"Coendou sp" ,
"Cuniculus paca",           
"Dasyprocta fuliginosa",      
"Dasypus novemcinctus" ,    
"Didelphis sp",    
"Eira barbara",  
"Herpailurus yagouaroundi",
"Leopardus pardalis",    
"Leopardus tigrinus" ,
"Leopardus wiedii",     
"Mazama murelia",
"Mazama zamora",
# "Mazama americana",
# "Mazama nemorivaga",
#"Mitu tuberosum" ,
"Myoprocta pratti",
"Myrmecophaga tridactyla",
"Nasua nasua" ,
# "Mazama americana",         
# "Myotis myotis",           
# "Nasua narica",             
# "Odocoileus virginianus",   
"Panthera onca" ,
# "Procyon cancrivorus" ,
"Pecari tajacu",    
#"Penelope jacquacu" ,
"Priodontes maximus" ,
"Procyon cancrivorus",      
# "Psophia leucoptera",
"Puma concolor" ,
# "Puma yagouaroundi",        
# "Rattus rattus" ,
# "Roedor sp.",
# "Sciurus sp.",       
# "Sus scrofa",               
# "Sylvilagus brasiliensis",  
"Speothos venaticus", 
"Tamandua tetradactyla",   
# "Tapirus pinchaque" ,
"Tapirus terrestris",
"Tayassu pecari"
#"Tinamus major"            
              )

# y.msom <- y[which(sp.codes %in% selected.sp), , ]
# str(y.msom)

# Use selection
y.selected <- ylist[selected.sp]   

#####################################
#### three-dimensional array with dimensions corresponding to:
#### species, sites, and replicates
#####################################

# 1. Load the abind library to make arrays easily 
library(abind)
my_array_abind <- abind(y.selected, # start from list
                        along = 3, # 3D array
                        use.first.dimnames=TRUE) # keep names

# Transpose the array to have:
# species, sites, and sampling occasions in that order
# The new order is (3rd dim, 1st dim, 2nd dim)
transposed_array <- aperm(my_array_abind, c(3, 1, 2))

#### site covs
sitecovs <- as.data.frame(st_drop_geometry(
                    data_full_sf_UTM[,5:8]))

 sitecovs[, 1] <- as.vector((sitecovs[,1]))   # scale numeric covariates
 sitecovs[, 1] <- as.numeric((sitecovs[,2]))   # scale numeric covariates
 sitecovs[, 3] <- as.vector((sitecovs[,3]))   # scale numeric covariates
 sitecovs[, 4] <- as.vector((sitecovs[,4]))   # scale numeric covariates
 # sitecovs$fact <- factor(c("A", "A", "B"))    # categorical covariate

names(sitecovs) <- c("elev", "in_AP", "FLII", "border_dist")

# check consistancy equal number of spatial covariates and rows in data
# identical(nrow(ylist[[1]]), nrow(covars)) 

# Base de datos para los análisis -----------------------------------------

# match the names to "y"  "occ.covs" "det.covs" "coords" 
data_list <- list(y = transposed_array, # Historias de detección
                  occ.covs = sitecovs, # covs de sitio
                  det.covs  = list(effort = DetHist_list[[1]]$effort),
                  coords = st_coordinates(data_full_sf_UTM)
                  )  # agregamos el esfuerzo de muestreo como covariable de observación

Running the model

We let spOccupancy set the initial values by default based on the prior distributions.

Code
# Running the model

# 3. 1 Modelo multi-especie  -----------------------------------------

# 2. Model fitting --------------------------------------------------------
# Fit a non-spatial, multi-species occupancy model. 
out.null <- msPGOcc(occ.formula = ~ scale(elev) +
                               scale(border_dist) + 
                               scale(FLII) , 
               det.formula = ~ scale(effort) , # Ordinal.day + I(Ordinal.day^2) + Year
                 data = data_list, 
                 n.samples = 6000, 
                 n.thin = 10, 
                 n.burn = 1000, 
                 n.chains = 3,
                 n.report = 1000);beep(sound = 4)
----------------------------------------
    Preparing to run the model
----------------------------------------
No prior specified for beta.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for alpha.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for tau.sq.beta.ig.
Setting prior shape to 0.1 and prior scale to 0.1
No prior specified for tau.sq.alpha.ig.
Setting prior shape to 0.1 and prior scale to 0.1
z is not specified in initial values.
Setting initial values based on observed data
beta.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
alpha.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
tau.sq.beta is not specified in initial values.
Setting initial values to random values between 0.5 and 10
tau.sq.alpha is not specified in initial values.
Setting to initial values to random values between 0.5 and 10
beta is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
alpha is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
----------------------------------------
    Model description
----------------------------------------
Multi-species Occupancy Model with Polya-Gamma latent
variable fit with 141 sites and 25 species.

Samples per Chain: 6000 
Burn-in: 1000 
Thinning Rate: 10 
Number of Chains: 3 
Total Posterior Samples: 1500 

Source compiled with OpenMP support and model fit using 1 thread(s).

----------------------------------------
    Chain 1
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
----------------------------------------
    Chain 2
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
----------------------------------------
    Chain 3
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
Code
summary(out.null, level = 'community')

Call:
msPGOcc(occ.formula = ~scale(elev) + scale(border_dist) + scale(FLII), 
    det.formula = ~scale(effort), data = data_list, n.samples = 6000, 
    n.report = 1000, n.burn = 1000, n.thin = 10, n.chains = 3)

Samples per Chain: 6000
Burn-in: 1000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 1500
Run Time (min): 2.5138

----------------------------------------
    Community Level
----------------------------------------
Occurrence Means (logit scale): 
                      Mean     SD    2.5%     50%   97.5%   Rhat ESS
(Intercept)        -1.3105 0.4167 -2.1151 -1.3082 -0.5148 1.0442 157
scale(elev)        -0.2105 0.1624 -0.5303 -0.2045  0.0971 1.0085 735
scale(border_dist) -0.5806 0.1508 -0.8967 -0.5826 -0.2902 1.0090 637
scale(FLII)         0.0528 0.1801 -0.2932  0.0504  0.4144 1.0122 798

Occurrence Variances (logit scale): 
                     Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)        3.0756 1.2796 1.3303 2.8007 6.3426 1.0158  419
scale(elev)        0.1524 0.0933 0.0384 0.1318 0.3974 1.0065 1171
scale(border_dist) 0.0833 0.0553 0.0230 0.0688 0.2167 1.0199  885
scale(FLII)        0.3553 0.2658 0.0769 0.2836 1.0298 1.0161  435

Detection Means (logit scale): 
                 Mean     SD    2.5%     50%   97.5%   Rhat  ESS
(Intercept)   -2.0070 0.3171 -2.6847 -1.9973 -1.4368 1.0094  333
scale(effort)  0.3076 0.0797  0.1546  0.3064  0.4735 1.0077 1500

Detection Variances (logit scale): 
                Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)   1.5704 0.7798 0.5276 1.4207 3.5072 1.0240  115
scale(effort) 0.0616 0.0362 0.0203 0.0529 0.1541 1.0132 1312
Code
# Fit a non-spatial, Latent Factor Multi-Species Occupancy Model. 
  out.lfMs <- msPGOcc(occ.formula = ~ scale(elev) +
                               scale(border_dist) + 
                               scale(FLII) , 
               det.formula = ~ scale(effort), # Ordinal.day + I(Ordinal.day^2) + Year
                 data = data_list, 
                 n.omp.threads = 6,
                 n.samples = 6000, 
                 n.factors = 5, # balance of rare sp. and run time
                 n.thin = 10, 
                 n.burn = 1000, 
                 n.chains = 3,
                 n.report = 1000);beep(sound = 4)
----------------------------------------
    Preparing to run the model
----------------------------------------
Warning in msPGOcc(occ.formula = ~scale(elev) + scale(border_dist) +
scale(FLII), : 'n.factors' is not an argument
No prior specified for beta.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for alpha.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for tau.sq.beta.ig.
Setting prior shape to 0.1 and prior scale to 0.1
No prior specified for tau.sq.alpha.ig.
Setting prior shape to 0.1 and prior scale to 0.1
z is not specified in initial values.
Setting initial values based on observed data
beta.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
alpha.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
tau.sq.beta is not specified in initial values.
Setting initial values to random values between 0.5 and 10
tau.sq.alpha is not specified in initial values.
Setting to initial values to random values between 0.5 and 10
beta is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
alpha is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
----------------------------------------
    Model description
----------------------------------------
Multi-species Occupancy Model with Polya-Gamma latent
variable fit with 141 sites and 25 species.

Samples per Chain: 6000 
Burn-in: 1000 
Thinning Rate: 10 
Number of Chains: 3 
Total Posterior Samples: 1500 

Source compiled with OpenMP support and model fit using 6 thread(s).

----------------------------------------
    Chain 1
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
----------------------------------------
    Chain 2
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
----------------------------------------
    Chain 3
----------------------------------------
Sampling ... 
Sampled: 1000 of 6000, 16.67%
-------------------------------------------------
Sampled: 2000 of 6000, 33.33%
-------------------------------------------------
Sampled: 3000 of 6000, 50.00%
-------------------------------------------------
Sampled: 4000 of 6000, 66.67%
-------------------------------------------------
Sampled: 5000 of 6000, 83.33%
-------------------------------------------------
Sampled: 6000 of 6000, 100.00%
Code
summary(out.lfMs, level = 'community')

Call:
msPGOcc(occ.formula = ~scale(elev) + scale(border_dist) + scale(FLII), 
    det.formula = ~scale(effort), data = data_list, n.samples = 6000, 
    n.omp.threads = 6, n.report = 1000, n.burn = 1000, n.thin = 10, 
    n.chains = 3, n.factors = 5)

Samples per Chain: 6000
Burn-in: 1000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 1500
Run Time (min): 2.4513

----------------------------------------
    Community Level
----------------------------------------
Occurrence Means (logit scale): 
                      Mean     SD    2.5%     50%   97.5%   Rhat ESS
(Intercept)        -1.3730 0.4235 -2.2148 -1.3615 -0.5564 1.0093 202
scale(elev)        -0.2155 0.1659 -0.5546 -0.2098  0.1009 1.0012 675
scale(border_dist) -0.5860 0.1468 -0.8753 -0.5809 -0.2894 1.0499 622
scale(FLII)         0.0397 0.1715 -0.2733  0.0310  0.4070 1.0043 735

Occurrence Variances (logit scale): 
                     Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)        3.1353 1.2452 1.3469 2.9029 6.3244 1.0060  504
scale(elev)        0.1506 0.0928 0.0392 0.1282 0.3889 1.0048 1032
scale(border_dist) 0.0817 0.0527 0.0239 0.0687 0.2284 1.0028 1136
scale(FLII)        0.3335 0.2425 0.0721 0.2723 0.9585 1.0007  469

Detection Means (logit scale): 
                 Mean     SD    2.5%     50%   97.5%   Rhat  ESS
(Intercept)   -1.9780 0.3088 -2.6604 -1.9477 -1.4650 1.0085  191
scale(effort)  0.3067 0.0808  0.1437  0.3074  0.4711 1.0029 1144

Detection Variances (logit scale): 
                Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)   1.4215 0.7287 0.4925 1.2440 3.3034 1.0388  112
scale(effort) 0.0591 0.0354 0.0195 0.0501 0.1552 1.0034 1127
Code
# Fit a Spatial Factor Multi-Species Occupancy Model
# latent spatial factors.
tictoc::tic()
  out.sp <- sfMsPGOcc(occ.formula = ~ scale(elev) +
                               scale(border_dist) + 
                               scale(FLII) , 
               det.formula = ~ scale(effort), # Ordinal.day + I(Ordinal.day^2) + Year,            
                      data = data_list, 
                      n.omp.threads = 6,
                      n.batch = 600, 
                      batch.length = 25, # iter=600*25
                      n.thin = 10, 
                      n.burn = 5000, 
                      n.chains = 3,
                      NNGP = TRUE,
                      n.factors = 5, # balance of rare sp. and run time
                      n.neighbors = 15,
                      cov.model = 'exponential',
                      n.report = 1000);beep(sound = 4)
----------------------------------------
    Preparing to run the model
----------------------------------------
No prior specified for beta.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for alpha.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for tau.sq.beta.
Using an inverse-Gamma prior with prior shape 0.1 and prior scale 0.1
No prior specified for tau.sq.alpha.
Using an inverse-Gamma prior with prior shape 0.1 and prior scale 0.1
No prior specified for phi.unif.
Setting uniform bounds based on the range of observed spatial coordinates.
z is not specified in initial values.
Setting initial values based on observed data
beta.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
alpha.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
tau.sq.beta is not specified in initial values.
Setting initial values to random values between 0.5 and 10
tau.sq.alpha is not specified in initial values.
Setting initial values to random values between 0.5 and 10
beta is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
alpha is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
phi is not specified in initial values.
Setting initial value to random values from the prior distribution
lambda is not specified in initial values.
Setting initial values of the lower triangle to 0
----------------------------------------
    Building the neighbor list
----------------------------------------
----------------------------------------
Building the neighbors of neighbors list
----------------------------------------
----------------------------------------
    Model description
----------------------------------------
Spatial Factor NNGP Multi-species Occupancy Model with Polya-Gamma latent
variable fit with 141 sites and 25 species.

Samples per chain: 15000 (600 batches of length 25)
Burn-in: 5000 
Thinning Rate: 10 
Number of Chains: 3 
Total Posterior Samples: 3000 

Using the exponential spatial correlation model.

Using 5 latent spatial factors.
Using 15 nearest neighbors.

Source compiled with OpenMP support and model fit using 6 thread(s).

Adaptive Metropolis with target acceptance rate: 43.0
----------------------------------------
    Chain 1
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
----------------------------------------
    Chain 2
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
----------------------------------------
    Chain 3
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
Code
tictoc::toc()
637.75 sec elapsed
Code
#########################
tictoc::tic()
  out.sp.cat <- sfMsPGOcc(occ.formula = ~ scale(elev) +
                               factor(in_AP) + 
                               scale(FLII) , 
               det.formula = ~ scale(effort), # Ordinal.day + I(Ordinal.day^2) + Year,            
                      data = data_list, 
                      n.omp.threads = 6,
                      n.batch = 600, 
                      batch.length = 25, # iter=600*25
                      n.thin = 10, 
                      n.burn = 5000, 
                      n.chains = 3,
                      NNGP = TRUE,
                      n.factors = 5, # balance of rare sp. and run time
                      n.neighbors = 15,
                      cov.model = 'exponential',
                      n.report = 1000);beep(sound = 4)
----------------------------------------
    Preparing to run the model
----------------------------------------
No prior specified for beta.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for alpha.comm.normal.
Setting prior mean to 0 and prior variance to 2.72
No prior specified for tau.sq.beta.
Using an inverse-Gamma prior with prior shape 0.1 and prior scale 0.1
No prior specified for tau.sq.alpha.
Using an inverse-Gamma prior with prior shape 0.1 and prior scale 0.1
No prior specified for phi.unif.
Setting uniform bounds based on the range of observed spatial coordinates.
z is not specified in initial values.
Setting initial values based on observed data
beta.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
alpha.comm is not specified in initial values.
Setting initial values to random values from the prior distribution
tau.sq.beta is not specified in initial values.
Setting initial values to random values between 0.5 and 10
tau.sq.alpha is not specified in initial values.
Setting initial values to random values between 0.5 and 10
beta is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
alpha is not specified in initial values.
Setting initial values to random values from the community-level normal distribution
phi is not specified in initial values.
Setting initial value to random values from the prior distribution
lambda is not specified in initial values.
Setting initial values of the lower triangle to 0
----------------------------------------
    Building the neighbor list
----------------------------------------
----------------------------------------
Building the neighbors of neighbors list
----------------------------------------
----------------------------------------
    Model description
----------------------------------------
Spatial Factor NNGP Multi-species Occupancy Model with Polya-Gamma latent
variable fit with 141 sites and 25 species.

Samples per chain: 15000 (600 batches of length 25)
Burn-in: 5000 
Thinning Rate: 10 
Number of Chains: 3 
Total Posterior Samples: 3000 

Using the exponential spatial correlation model.

Using 5 latent spatial factors.
Using 15 nearest neighbors.

Source compiled with OpenMP support and model fit using 6 thread(s).

Adaptive Metropolis with target acceptance rate: 43.0
----------------------------------------
    Chain 1
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
----------------------------------------
    Chain 2
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
----------------------------------------
    Chain 3
----------------------------------------
Sampling ... 
Batch: 600 of 600, 100.00%
Code
tictoc::toc()
630.81 sec elapsed
Code
# tictoc::tic()
#   out.sp.gaus <- sfMsPGOcc(occ.formula = ~ scale(border_dist) , 
#                            det.formula = ~ scale(effort), # Ordinal.day + I(Ordinal.day^2) + Year,              
#                            data = data_list, 
#                            n.batch = 400, 
#                            batch.length = 25,
#                            n.thin = 5, 
#                            n.burn = 5000, 
#                            n.chains = 1,
#                            NNGP = TRUE,
#                            n.factors = 5,
#                            n.neighbors = 15,
#                            cov.model = 'gaussian',
#                            n.report = 100);beep(sound = 4)
# tictoc::toc()

# save the results to not run again
# save(out, file="C:/CodigoR/Occu_APs_all/blog/2025-10-15-analysis/result/result_2.R") # guardamos los resultados para no correr de nuevo
# save the results to not run again
# save(out.sp, file="C:/CodigoR/Occu_APs_all/blog/2025-10-15-analysis/result/sp_result_2.R") # guardamos los resultados para no correr de nuevo

# save(out.lfMs, file="C:/CodigoR/Occu_APs_all/blog/2025-10-15-analysis/result/lfms_result_2.R") # guardamos los resultados para no correr de nuevo


# load("C:/CodigoR/Occu_APs_all/blog/2025-10-15-analysis/result/sp_result_2.R")
# summary(fit.commu)

Model validation

We next perform a posterior predictive check using the Freeman-Tukey statistic grouping the data by sites. We summarize the posterior predictive check with the summary() function, which reports a Bayesian p-value. A Bayesian p-value that hovers around 0.5 indicates adequate model fit, while values less than 0.1 or greater than 0.9 suggest our model does not fit the data well (Hobbs and Hooten 2015). As always with a simulation-based analysis using MCMC, you will get numerically slightly different values.

Code
# 3. Model validation -----------------------------------------------------
# Perform a posterior predictive check to assess model fit. 
ppc.out <- ppcOcc(out.null, fit.stat = 'freeman-tukey', 
                  group = 1)
ppc.out.lfMs <- ppcOcc(out.lfMs, fit.stat = 'freeman-tukey', 
                  group = 1)
ppc.out.sp <- ppcOcc(out.sp, fit.stat = 'freeman-tukey',
                     group = 1)

# Calculate a Bayesian p-value as a simple measure of Goodness of Fit.
# Bayesian p-values between 0.1 and 0.9 indicate adequate model fit. 
summary(ppc.out)

Call:
ppcOcc(object = out.null, fit.stat = "freeman-tukey", group = 1)

Samples per Chain: 6000
Burn-in: 1000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 1500

----------------------------------------
    Community Level
----------------------------------------
Bayesian p-value:  0.3974 

----------------------------------------
    Species Level
----------------------------------------
Atelocynus microtis Bayesian p-value: 0.4387
Coendou sp Bayesian p-value: 0.5187
Cuniculus paca Bayesian p-value: 0.066
Dasyprocta fuliginosa Bayesian p-value: 0.0747
Dasypus novemcinctus Bayesian p-value: 0.3667
Didelphis sp Bayesian p-value: 0.472
Eira barbara Bayesian p-value: 0.4567
Herpailurus yagouaroundi Bayesian p-value: 0.6293
Leopardus pardalis Bayesian p-value: 0.3467
Leopardus tigrinus Bayesian p-value: 0.2493
Leopardus wiedii Bayesian p-value: 0.3733
Mazama murelia Bayesian p-value: 0.3607
Mazama zamora Bayesian p-value: 0.3567
Myoprocta pratti Bayesian p-value: 0.414
Myrmecophaga tridactyla Bayesian p-value: 0.55
Nasua nasua Bayesian p-value: 0.5653
Panthera onca Bayesian p-value: 0.4607
Pecari tajacu Bayesian p-value: 0.3233
Priodontes maximus Bayesian p-value: 0.6093
Procyon cancrivorus Bayesian p-value: 0.382
Puma concolor Bayesian p-value: 0.446
Speothos venaticus Bayesian p-value: 0.4853
Tamandua tetradactyla Bayesian p-value: 0.302
Tapirus terrestris Bayesian p-value: 0.262
Tayassu pecari Bayesian p-value: 0.4247
Fit statistic:  freeman-tukey 
Code
summary(ppc.out.lfMs)

Call:
ppcOcc(object = out.lfMs, fit.stat = "freeman-tukey", group = 1)

Samples per Chain: 6000
Burn-in: 1000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 1500

----------------------------------------
    Community Level
----------------------------------------
Bayesian p-value:  0.4032 

----------------------------------------
    Species Level
----------------------------------------
Atelocynus microtis Bayesian p-value: 0.4653
Coendou sp Bayesian p-value: 0.5187
Cuniculus paca Bayesian p-value: 0.0673
Dasyprocta fuliginosa Bayesian p-value: 0.058
Dasypus novemcinctus Bayesian p-value: 0.3347
Didelphis sp Bayesian p-value: 0.4787
Eira barbara Bayesian p-value: 0.4793
Herpailurus yagouaroundi Bayesian p-value: 0.638
Leopardus pardalis Bayesian p-value: 0.328
Leopardus tigrinus Bayesian p-value: 0.2533
Leopardus wiedii Bayesian p-value: 0.3867
Mazama murelia Bayesian p-value: 0.358
Mazama zamora Bayesian p-value: 0.3453
Myoprocta pratti Bayesian p-value: 0.4187
Myrmecophaga tridactyla Bayesian p-value: 0.5947
Nasua nasua Bayesian p-value: 0.5727
Panthera onca Bayesian p-value: 0.4933
Pecari tajacu Bayesian p-value: 0.2987
Priodontes maximus Bayesian p-value: 0.6227
Procyon cancrivorus Bayesian p-value: 0.3913
Puma concolor Bayesian p-value: 0.452
Speothos venaticus Bayesian p-value: 0.4933
Tamandua tetradactyla Bayesian p-value: 0.3133
Tapirus terrestris Bayesian p-value: 0.272
Tayassu pecari Bayesian p-value: 0.4453
Fit statistic:  freeman-tukey 
Code
summary(ppc.out.sp)

Call:
ppcOcc(object = out.sp, fit.stat = "freeman-tukey", group = 1)

Samples per Chain: 15000
Burn-in: 5000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 3000

----------------------------------------
    Community Level
----------------------------------------
Bayesian p-value:  0.3952 

----------------------------------------
    Species Level
----------------------------------------
Atelocynus microtis Bayesian p-value: 0.4613
Coendou sp Bayesian p-value: 0.531
Cuniculus paca Bayesian p-value: 0.0653
Dasyprocta fuliginosa Bayesian p-value: 0.0883
Dasypus novemcinctus Bayesian p-value: 0.2603
Didelphis sp Bayesian p-value: 0.4987
Eira barbara Bayesian p-value: 0.487
Herpailurus yagouaroundi Bayesian p-value: 0.6153
Leopardus pardalis Bayesian p-value: 0.4347
Leopardus tigrinus Bayesian p-value: 0.261
Leopardus wiedii Bayesian p-value: 0.367
Mazama murelia Bayesian p-value: 0.2633
Mazama zamora Bayesian p-value: 0.3557
Myoprocta pratti Bayesian p-value: 0.424
Myrmecophaga tridactyla Bayesian p-value: 0.629
Nasua nasua Bayesian p-value: 0.5717
Panthera onca Bayesian p-value: 0.4383
Pecari tajacu Bayesian p-value: 0.2843
Priodontes maximus Bayesian p-value: 0.5697
Procyon cancrivorus Bayesian p-value: 0.3777
Puma concolor Bayesian p-value: 0.4577
Speothos venaticus Bayesian p-value: 0.5477
Tamandua tetradactyla Bayesian p-value: 0.3147
Tapirus terrestris Bayesian p-value: 0.1943
Tayassu pecari Bayesian p-value: 0.3813
Fit statistic:  freeman-tukey 
Important

A Bayesian p-value that around 0.5 indicates adequate model fit, while values less than 0.1 or greater than 0.9 suggest our model does not fit the data well.

Fit plot

Code
#### fit plot
ppc.df <- data.frame(fit = ppc.out.sp$fit.y, 
                     fit.rep = ppc.out.sp$fit.y.rep, 
                     color = 'lightskyblue1')

ppc.df$color[ppc.df$fit.rep.1 > ppc.df$fit.1] <- 'lightsalmon'
plot(ppc.df$fit.1, ppc.df$fit.rep.1, bg = ppc.df$color, pch = 21, 
     ylab = 'Fit', xlab = 'True')
lines(ppc.df$fit.1, ppc.df$fit.1, col = 'black')

The most symmetrical, better fit!

The most symmetrical, better fit!

Model comparison

Code
# 4. Model comparison -----------------------------------------------------
# Compute Widely Applicable Information Criterion (WAIC)
# Lower values indicate better model fit. 
waicOcc(out.null)
       elpd          pD        WAIC 
-3261.38437    81.61097  6685.99068 
Code
waicOcc(out.lfMs)
       elpd          pD        WAIC 
-3261.87081    82.07571  6687.89304 
Code
waicOcc(out.sp)
      elpd         pD       WAIC 
-2937.7749   346.2816  6568.1129 
Code
waicOcc(out.sp.cat)
      elpd         pD       WAIC 
-2934.5311   348.7836  6566.6294 

Model comparison as table

Code
# Here we summarize the spatial factor loadings
# summary(out.sp$lambda.samples)

# Resultados --------------------------------------------------------------
# Extraemos lo tabla de valores estimados
modresult <- cbind(as.data.frame(waicOcc(out.null)),
                  as.data.frame(waicOcc(out.sp)),
                  as.data.frame(waicOcc(out.lfMs)),
                  as.data.frame(waicOcc(out.sp.cat))
                  #as.data.frame(waicOcc(out.sp.gaus))
                  )
# View(modresult)
modresult_sorted <- as.data.frame(t(modresult)) |> 
  arrange(WAIC) # sort by
  
DT::datatable(modresult_sorted)
Important

Lower values in WAIC indicate better model fit.

WAIC is the Widely Applicable Information Criterion (Watanabe 2010).

Posterior Summary

Code
# 5. Posterior summaries --------------------------------------------------
# Concise summary of main parameter estimates
summary(out.sp, level = 'community')

Call:
sfMsPGOcc(occ.formula = ~scale(elev) + scale(border_dist) + scale(FLII), 
    det.formula = ~scale(effort), data = data_list, cov.model = "exponential", 
    NNGP = TRUE, n.neighbors = 15, n.factors = 5, n.batch = 600, 
    batch.length = 25, n.omp.threads = 6, n.report = 1000, n.burn = 5000, 
    n.thin = 10, n.chains = 3)

Samples per Chain: 15000
Burn-in: 5000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 3000
Run Time (min): 10.6275

----------------------------------------
    Community Level
----------------------------------------
Occurrence Means (logit scale): 
                      Mean     SD    2.5%     50%   97.5%   Rhat ESS
(Intercept)        -1.9004 0.5780 -3.0373 -1.9005 -0.7742 1.0117 252
scale(elev)        -0.3026 0.2473 -0.7818 -0.3017  0.1768 1.0123 915
scale(border_dist) -0.8487 0.2246 -1.2976 -0.8398 -0.4210 1.0113 667
scale(FLII)         0.0366 0.2443 -0.4179  0.0220  0.5447 1.0238 915

Occurrence Variances (logit scale): 
                     Mean     SD   2.5%    50%   97.5%   Rhat  ESS
(Intercept)        6.5946 2.7326 2.8517 6.1052 13.0779 1.0046  430
scale(elev)        0.3012 0.2088 0.0574 0.2514  0.8286 1.0162 1148
scale(border_dist) 0.1369 0.1078 0.0275 0.1051  0.4098 1.0052 1789
scale(FLII)        0.6414 0.4785 0.1017 0.5174  1.8928 1.0109  804

Detection Means (logit scale): 
                 Mean     SD   2.5%     50%   97.5%   Rhat  ESS
(Intercept)   -2.0014 0.3122 -2.651 -1.9877 -1.4357 1.0316  250
scale(effort)  0.3091 0.0812  0.150  0.3070  0.4742 0.9998 2683

Detection Variances (logit scale): 
                Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)   1.5312 0.7843 0.5186 1.3647 3.5614 1.0183  118
scale(effort) 0.0615 0.0364 0.0200 0.0526 0.1530 1.0051 2660

----------------------------------------
    Spatial Covariance
----------------------------------------
         Mean     SD   2.5%     50%   97.5%   Rhat  ESS
phi-1 13.7269 8.0014 0.6750 13.9028 26.6418 1.0007 2843
phi-2 13.7322 7.9105 0.7179 13.6774 26.8470 1.0049 3000
phi-3 13.4748 8.0759 0.4572 13.0370 26.9249 1.0008 2609
phi-4 13.6439 7.9863 0.5321 13.5390 26.8039 1.0014 2827
phi-5 13.5677 8.0831 0.6575 13.5918 26.8284 1.0028 3000
Code
summary(out.sp, level = 'species')

Call:
sfMsPGOcc(occ.formula = ~scale(elev) + scale(border_dist) + scale(FLII), 
    det.formula = ~scale(effort), data = data_list, cov.model = "exponential", 
    NNGP = TRUE, n.neighbors = 15, n.factors = 5, n.batch = 600, 
    batch.length = 25, n.omp.threads = 6, n.report = 1000, n.burn = 5000, 
    n.thin = 10, n.chains = 3)

Samples per Chain: 15000
Burn-in: 5000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 3000
Run Time (min): 10.6275

----------------------------------------
    Species Level
----------------------------------------
Occurrence (logit scale): 
                                               Mean     SD    2.5%     50%
(Intercept)-Atelocynus microtis             -2.5128 1.3030 -4.2470 -2.7335
(Intercept)-Coendou sp                      -3.9762 1.7049 -6.9045 -4.1516
(Intercept)-Cuniculus paca                   0.1870 0.2871 -0.3508  0.1811
(Intercept)-Dasyprocta fuliginosa            0.2738 0.3517 -0.3876  0.2628
(Intercept)-Dasypus novemcinctus            -2.0688 0.6222 -3.4132 -2.0190
(Intercept)-Didelphis sp                    -4.2873 2.0842 -7.7730 -4.5076
(Intercept)-Eira barbara                    -3.7574 1.3940 -6.3749 -3.8243
(Intercept)-Herpailurus yagouaroundi        -1.9744 1.6957 -5.0297 -2.0878
(Intercept)-Leopardus pardalis              -2.0684 0.6689 -3.3723 -2.0609
(Intercept)-Leopardus tigrinus              -6.0705 1.2850 -8.7898 -5.9842
(Intercept)-Leopardus wiedii                -4.1753 1.4582 -6.9157 -4.2085
(Intercept)-Mazama murelia                  -0.5998 0.7635 -1.9557 -0.6517
(Intercept)-Mazama zamora                    1.7925 0.5106  0.9311  1.7438
(Intercept)-Myoprocta pratti                -3.8449 0.7404 -5.4724 -3.7841
(Intercept)-Myrmecophaga tridactyla         -1.6157 1.3187 -3.9155 -1.6979
(Intercept)-Nasua nasua                     -4.0631 1.6847 -7.1178 -4.2048
(Intercept)-Panthera onca                   -0.8588 0.9750 -2.5945 -0.9424
(Intercept)-Pecari tajacu                    1.7134 0.5536  0.8385  1.6424
(Intercept)-Priodontes maximus              -0.1326 1.6703 -2.8466 -0.3335
(Intercept)-Procyon cancrivorus             -3.9133 1.0701 -6.1357 -3.8848
(Intercept)-Puma concolor                   -1.8649 0.5259 -3.0144 -1.8428
(Intercept)-Speothos venaticus              -4.2986 1.9431 -7.8873 -4.4031
(Intercept)-Tamandua tetradactyla           -4.3434 1.6741 -7.2208 -4.5284
(Intercept)-Tapirus terrestris               0.9599 0.4889  0.1531  0.9020
(Intercept)-Tayassu pecari                  -0.4809 0.4429 -1.3248 -0.4893
scale(elev)-Atelocynus microtis             -0.4737 0.4916 -1.4352 -0.4755
scale(elev)-Coendou sp                      -0.4648 0.5374 -1.5933 -0.4436
scale(elev)-Cuniculus paca                  -0.3584 0.3405 -1.0283 -0.3596
scale(elev)-Dasyprocta fuliginosa            0.1427 0.4049 -0.6018  0.1329
scale(elev)-Dasypus novemcinctus            -0.3089 0.4063 -1.0970 -0.3108
scale(elev)-Didelphis sp                    -0.1234 0.5432 -1.1716 -0.1300
scale(elev)-Eira barbara                    -0.3241 0.5036 -1.2994 -0.3176
scale(elev)-Herpailurus yagouaroundi        -0.3332 0.5282 -1.3915 -0.3369
scale(elev)-Leopardus pardalis              -0.3590 0.4296 -1.1894 -0.3689
scale(elev)-Leopardus tigrinus              -0.5066 0.5458 -1.6443 -0.4849
scale(elev)-Leopardus wiedii                -0.1668 0.5010 -1.1384 -0.1912
scale(elev)-Mazama murelia                  -0.5848 0.4503 -1.4943 -0.5733
scale(elev)-Mazama zamora                   -0.0811 0.4324 -0.8885 -0.1022
scale(elev)-Myoprocta pratti                -0.2542 0.4240 -1.0929 -0.2532
scale(elev)-Myrmecophaga tridactyla         -0.3651 0.5071 -1.3814 -0.3689
scale(elev)-Nasua nasua                     -0.5416 0.5578 -1.7241 -0.5147
scale(elev)-Panthera onca                   -0.3542 0.4677 -1.2756 -0.3528
scale(elev)-Pecari tajacu                   -0.4186 0.4285 -1.2528 -0.4325
scale(elev)-Priodontes maximus              -0.3171 0.5253 -1.3301 -0.3326
scale(elev)-Procyon cancrivorus              0.0140 0.4911 -0.8936 -0.0129
scale(elev)-Puma concolor                   -1.0840 0.4727 -2.0723 -1.0631
scale(elev)-Speothos venaticus              -0.4682 0.5558 -1.5677 -0.4544
scale(elev)-Tamandua tetradactyla           -0.2614 0.5054 -1.2328 -0.2749
scale(elev)-Tapirus terrestris              -0.0707 0.4335 -0.8511 -0.0876
scale(elev)-Tayassu pecari                   0.4808 0.4725 -0.3824  0.4538
scale(border_dist)-Atelocynus microtis      -0.6828 0.3904 -1.4292 -0.6927
scale(border_dist)-Coendou sp               -0.7873 0.4206 -1.6252 -0.7901
scale(border_dist)-Cuniculus paca           -0.8343 0.3092 -1.4602 -0.8327
scale(border_dist)-Dasyprocta fuliginosa    -0.9597 0.3458 -1.6666 -0.9450
scale(border_dist)-Dasypus novemcinctus     -0.6013 0.3597 -1.2652 -0.6165
scale(border_dist)-Didelphis sp             -0.9018 0.4135 -1.7471 -0.8808
scale(border_dist)-Eira barbara             -0.7756 0.4022 -1.5474 -0.7793
scale(border_dist)-Herpailurus yagouaroundi -0.8359 0.4126 -1.6615 -0.8410
scale(border_dist)-Leopardus pardalis       -0.8647 0.3666 -1.5620 -0.8684
scale(border_dist)-Leopardus tigrinus       -0.7717 0.4101 -1.5623 -0.7772
scale(border_dist)-Leopardus wiedii         -0.8336 0.3910 -1.6125 -0.8316
scale(border_dist)-Mazama murelia           -0.7455 0.3734 -1.4664 -0.7487
scale(border_dist)-Mazama zamora            -0.9256 0.3338 -1.5856 -0.9125
scale(border_dist)-Myoprocta pratti         -0.9819 0.3812 -1.7840 -0.9648
scale(border_dist)-Myrmecophaga tridactyla  -0.9126 0.3916 -1.7340 -0.8963
scale(border_dist)-Nasua nasua              -0.8221 0.4291 -1.6939 -0.8266
scale(border_dist)-Panthera onca            -1.0082 0.3920 -1.8357 -0.9932
scale(border_dist)-Pecari tajacu            -0.8686 0.3469 -1.5899 -0.8577
scale(border_dist)-Priodontes maximus       -0.8037 0.4097 -1.6193 -0.8029
scale(border_dist)-Procyon cancrivorus      -0.9930 0.4051 -1.8558 -0.9753
scale(border_dist)-Puma concolor            -0.7343 0.3518 -1.4148 -0.7384
scale(border_dist)-Speothos venaticus       -0.7537 0.4195 -1.5706 -0.7587
scale(border_dist)-Tamandua tetradactyla    -0.8058 0.3967 -1.5666 -0.8049
scale(border_dist)-Tapirus terrestris       -0.9506 0.3504 -1.6711 -0.9357
scale(border_dist)-Tayassu pecari           -1.0954 0.3808 -1.9312 -1.0723
scale(FLII)-Atelocynus microtis             -0.5822 0.4303 -1.5873 -0.5403
scale(FLII)-Coendou sp                       0.2433 0.7441 -1.1468  0.1913
scale(FLII)-Cuniculus paca                  -0.5901 0.3702 -1.4146 -0.5548
scale(FLII)-Dasyprocta fuliginosa           -0.7084 0.4406 -1.6551 -0.6645
scale(FLII)-Dasypus novemcinctus            -0.6336 0.4623 -1.7114 -0.5728
scale(FLII)-Didelphis sp                     0.2202 0.7862 -1.2759  0.1918
scale(FLII)-Eira barbara                     0.0436 0.6483 -1.2252  0.0300
scale(FLII)-Herpailurus yagouaroundi        -0.0460 0.7452 -1.6217 -0.0418
scale(FLII)-Leopardus pardalis               0.4831 0.5475 -0.4671  0.4366
scale(FLII)-Leopardus tigrinus               0.2894 0.6830 -0.8272  0.2082
scale(FLII)-Leopardus wiedii                -0.0673 0.6794 -1.5194 -0.0411
scale(FLII)-Mazama murelia                  -0.0856 0.4245 -0.9453 -0.0700
scale(FLII)-Mazama zamora                   -0.5200 0.4830 -1.6106 -0.4682
scale(FLII)-Myoprocta pratti                 0.2775 0.5018 -0.5905  0.2323
scale(FLII)-Myrmecophaga tridactyla          0.2257 0.6762 -1.0848  0.2200
scale(FLII)-Nasua nasua                      0.2968 0.7568 -1.0586  0.2254
scale(FLII)-Panthera onca                    0.7468 0.6968 -0.4501  0.6853
scale(FLII)-Pecari tajacu                   -0.2823 0.4112 -1.1886 -0.2508
scale(FLII)-Priodontes maximus               0.2659 0.7464 -1.1339  0.2174
scale(FLII)-Procyon cancrivorus             -0.7344 0.5369 -1.9682 -0.6613
scale(FLII)-Puma concolor                    1.1210 0.7357 -0.0587  1.0392
scale(FLII)-Speothos venaticus               0.1914 0.7821 -1.2241  0.1237
scale(FLII)-Tamandua tetradactyla            0.2533 0.6923 -0.9948  0.1895
scale(FLII)-Tapirus terrestris              -0.1850 0.3755 -0.9681 -0.1673
scale(FLII)-Tayassu pecari                   0.7364 0.5095 -0.2023  0.7009
                                              97.5%   Rhat  ESS
(Intercept)-Atelocynus microtis              0.9057 1.0699  168
(Intercept)-Coendou sp                      -0.0131 1.0107  133
(Intercept)-Cuniculus paca                   0.7849 1.0005 2379
(Intercept)-Dasyprocta fuliginosa            0.9908 1.0000 2935
(Intercept)-Dasypus novemcinctus            -0.9040 1.0034 1038
(Intercept)-Didelphis sp                     0.8428 1.0649  111
(Intercept)-Eira barbara                    -0.7099 1.0580  276
(Intercept)-Herpailurus yagouaroundi         1.8817 1.1131  185
(Intercept)-Leopardus pardalis              -0.7518 1.0106  978
(Intercept)-Leopardus tigrinus              -3.7877 1.0057  697
(Intercept)-Leopardus wiedii                -1.1875 1.0046  178
(Intercept)-Mazama murelia                   1.1361 1.0168  633
(Intercept)-Mazama zamora                    2.9254 1.0034 1539
(Intercept)-Myoprocta pratti                -2.5805 1.0051 1123
(Intercept)-Myrmecophaga tridactyla          1.3455 1.0430  252
(Intercept)-Nasua nasua                     -0.3296 1.0141  165
(Intercept)-Panthera onca                    1.3283 1.0043  427
(Intercept)-Pecari tajacu                    3.0087 1.0060 1390
(Intercept)-Priodontes maximus               3.7599 1.0732  195
(Intercept)-Procyon cancrivorus             -1.8585 1.0316  640
(Intercept)-Puma concolor                   -0.9251 1.0021 1597
(Intercept)-Speothos venaticus              -0.3298 1.0562  156
(Intercept)-Tamandua tetradactyla           -0.3395 1.0428  223
(Intercept)-Tapirus terrestris               2.1000 1.0086 1512
(Intercept)-Tayassu pecari                   0.4260 1.0006 1809
scale(elev)-Atelocynus microtis              0.4951 1.0043 1564
scale(elev)-Coendou sp                       0.5385 1.0143 1282
scale(elev)-Cuniculus paca                   0.3111 1.0096 1398
scale(elev)-Dasyprocta fuliginosa            0.9748 1.0041 1294
scale(elev)-Dasypus novemcinctus             0.4791 1.0005 1946
scale(elev)-Didelphis sp                     1.0063 1.0096 1587
scale(elev)-Eira barbara                     0.6523 1.0048 1500
scale(elev)-Herpailurus yagouaroundi         0.7446 1.0101 1433
scale(elev)-Leopardus pardalis               0.4853 1.0052 1510
scale(elev)-Leopardus tigrinus               0.5245 1.0074 1799
scale(elev)-Leopardus wiedii                 0.8687 1.0129 1580
scale(elev)-Mazama murelia                   0.2666 1.0008 1550
scale(elev)-Mazama zamora                    0.8440 1.0118 1741
scale(elev)-Myoprocta pratti                 0.5643 1.0004 1802
scale(elev)-Myrmecophaga tridactyla          0.6118 1.0084 1239
scale(elev)-Nasua nasua                      0.4557 1.0045 1403
scale(elev)-Panthera onca                    0.5669 1.0074 1660
scale(elev)-Pecari tajacu                    0.4392 1.0035 1783
scale(elev)-Priodontes maximus               0.7670 1.0126 1494
scale(elev)-Procyon cancrivorus              1.0490 1.0030 1800
scale(elev)-Puma concolor                   -0.2185 1.0001 1573
scale(elev)-Speothos venaticus               0.5765 1.0039 1441
scale(elev)-Tamandua tetradactyla            0.7672 1.0006 1454
scale(elev)-Tapirus terrestris               0.8665 1.0161 1644
scale(elev)-Tayassu pecari                   1.5357 1.0087 1117
scale(border_dist)-Atelocynus microtis       0.1190 1.0047 1211
scale(border_dist)-Coendou sp                0.0695 1.0078 1480
scale(border_dist)-Cuniculus paca           -0.2372 1.0189 1349
scale(border_dist)-Dasyprocta fuliginosa    -0.3054 1.0107 1427
scale(border_dist)-Dasypus novemcinctus      0.1536 1.0030 1567
scale(border_dist)-Didelphis sp             -0.1091 1.0007 1518
scale(border_dist)-Eira barbara              0.0307 1.0028 1637
scale(border_dist)-Herpailurus yagouaroundi -0.0069 1.0002 1296
scale(border_dist)-Leopardus pardalis       -0.1439 1.0063 1462
scale(border_dist)-Leopardus tigrinus        0.0353 1.0057 1365
scale(border_dist)-Leopardus wiedii         -0.0501 1.0004 1306
scale(border_dist)-Mazama murelia           -0.0088 1.0010 1664
scale(border_dist)-Mazama zamora            -0.3030 1.0159 1442
scale(border_dist)-Myoprocta pratti         -0.2671 1.0008 1302
scale(border_dist)-Myrmecophaga tridactyla  -0.1750 1.0011 1406
scale(border_dist)-Nasua nasua               0.0470 1.0015 1351
scale(border_dist)-Panthera onca            -0.2805 1.0037 1481
scale(border_dist)-Pecari tajacu            -0.1899 1.0152 1414
scale(border_dist)-Priodontes maximus        0.0492 1.0029 1372
scale(border_dist)-Procyon cancrivorus      -0.2398 1.0021 1491
scale(border_dist)-Puma concolor            -0.0398 1.0034 1527
scale(border_dist)-Speothos venaticus        0.1245 1.0077 1428
scale(border_dist)-Tamandua tetradactyla     0.0005 1.0095 1420
scale(border_dist)-Tapirus terrestris       -0.2964 1.0091 1380
scale(border_dist)-Tayassu pecari           -0.3936 1.0200 1456
scale(FLII)-Atelocynus microtis              0.1792 1.0019 1939
scale(FLII)-Coendou sp                       1.8244 1.0065 1180
scale(FLII)-Cuniculus paca                   0.0244 1.0078 1509
scale(FLII)-Dasyprocta fuliginosa            0.0643 1.0199 2318
scale(FLII)-Dasypus novemcinctus             0.1033 1.0037 1772
scale(FLII)-Didelphis sp                     1.9119 1.0118 1160
scale(FLII)-Eira barbara                     1.3484 1.0097 1687
scale(FLII)-Herpailurus yagouaroundi         1.4892 1.0260 1262
scale(FLII)-Leopardus pardalis               1.6661 1.0006 1781
scale(FLII)-Leopardus tigrinus               1.8227 1.0002 1558
scale(FLII)-Leopardus wiedii                 1.2383 1.0193 1021
scale(FLII)-Mazama murelia                   0.7201 1.0047 2158
scale(FLII)-Mazama zamora                    0.2747 1.0179 1909
scale(FLII)-Myoprocta pratti                 1.3658 1.0022 1972
scale(FLII)-Myrmecophaga tridactyla          1.5975 1.0014 1137
scale(FLII)-Nasua nasua                      1.9858 1.0153 1256
scale(FLII)-Panthera onca                    2.3258 1.0076 1131
scale(FLII)-Pecari tajacu                    0.4494 1.0149 2245
scale(FLII)-Priodontes maximus               1.8764 1.0047 1082
scale(FLII)-Procyon cancrivorus              0.1262 1.0281 1893
scale(FLII)-Puma concolor                    2.7303 1.0028  962
scale(FLII)-Speothos venaticus               1.9324 1.0075 1258
scale(FLII)-Tamandua tetradactyla            1.8139 1.0142 1411
scale(FLII)-Tapirus terrestris               0.5039 1.0138 2579
scale(FLII)-Tayassu pecari                   1.8270 1.0022 1445

Detection (logit scale): 
                                          Mean     SD    2.5%     50%   97.5%
(Intercept)-Atelocynus microtis        -2.6640 0.7999 -4.5022 -2.5970 -1.2942
(Intercept)-Coendou sp                 -3.1213 1.2292 -5.6345 -3.0436 -0.9605
(Intercept)-Cuniculus paca             -0.4806 0.1152 -0.7069 -0.4816 -0.2554
(Intercept)-Dasyprocta fuliginosa      -0.4248 0.1084 -0.6379 -0.4248 -0.2151
(Intercept)-Dasypus novemcinctus       -1.5136 0.2979 -2.1107 -1.5065 -0.9523
(Intercept)-Didelphis sp               -3.3004 1.2734 -5.9456 -3.2340 -1.0734
(Intercept)-Eira barbara               -2.6661 0.7242 -4.1821 -2.6241 -1.3653
(Intercept)-Herpailurus yagouaroundi   -3.4650 0.7675 -4.9060 -3.4801 -1.9549
(Intercept)-Leopardus pardalis         -1.6917 0.2726 -2.2718 -1.6857 -1.1822
(Intercept)-Leopardus tigrinus         -1.1396 0.9360 -3.0844 -1.0886  0.5774
(Intercept)-Leopardus wiedii           -2.6587 0.8582 -4.4724 -2.6035 -1.1289
(Intercept)-Mazama murelia             -1.9624 0.2870 -2.5581 -1.9539 -1.4265
(Intercept)-Mazama zamora              -0.8281 0.1063 -1.0403 -0.8248 -0.6231
(Intercept)-Myoprocta pratti           -0.9037 0.3046 -1.5301 -0.8901 -0.3558
(Intercept)-Myrmecophaga tridactyla    -2.8685 0.5125 -3.9003 -2.8584 -1.8662
(Intercept)-Nasua nasua                -3.1380 1.0257 -5.2303 -3.0960 -1.2575
(Intercept)-Panthera onca              -2.4220 0.3707 -3.1502 -2.4132 -1.7266
(Intercept)-Pecari tajacu              -0.9121 0.1124 -1.1307 -0.9122 -0.7039
(Intercept)-Priodontes maximus         -3.2774 0.5092 -4.2182 -3.2985 -2.2419
(Intercept)-Procyon cancrivorus        -2.1652 0.5989 -3.3968 -2.1425 -1.0957
(Intercept)-Puma concolor              -1.3238 0.2195 -1.7619 -1.3225 -0.9137
(Intercept)-Speothos venaticus         -3.2914 1.2116 -5.5791 -3.2835 -1.0536
(Intercept)-Tamandua tetradactyla      -2.6054 1.0292 -4.9165 -2.5023 -0.8333
(Intercept)-Tapirus terrestris         -1.0407 0.1320 -1.3054 -1.0399 -0.7991
(Intercept)-Tayassu pecari             -1.4252 0.1875 -1.7961 -1.4265 -1.0596
scale(effort)-Atelocynus microtis       0.3561 0.2369 -0.0983  0.3504  0.8301
scale(effort)-Coendou sp                0.3192 0.2536 -0.1936  0.3218  0.8377
scale(effort)-Cuniculus paca            0.3441 0.1106  0.1318  0.3421  0.5694
scale(effort)-Dasyprocta fuliginosa     0.3194 0.1027  0.1299  0.3171  0.5282
scale(effort)-Dasypus novemcinctus      0.3068 0.1752 -0.0191  0.2993  0.6669
scale(effort)-Didelphis sp              0.3158 0.2521 -0.1678  0.3163  0.8139
scale(effort)-Eira barbara              0.3912 0.2400 -0.0483  0.3789  0.9177
scale(effort)-Herpailurus yagouaroundi  0.1573 0.2311 -0.3157  0.1649  0.6086
scale(effort)-Leopardus pardalis        0.1759 0.1652 -0.1429  0.1729  0.5081
scale(effort)-Leopardus tigrinus        0.3663 0.2540 -0.1170  0.3596  0.8946
scale(effort)-Leopardus wiedii          0.3468 0.2438 -0.1115  0.3388  0.8527
scale(effort)-Mazama murelia            0.5080 0.1977  0.1633  0.4925  0.9449
scale(effort)-Mazama zamora             0.3904 0.1067  0.1972  0.3866  0.6126
scale(effort)-Myoprocta pratti          0.2838 0.2008 -0.1012  0.2820  0.6847
scale(effort)-Myrmecophaga tridactyla   0.3333 0.2119 -0.0758  0.3267  0.7775
scale(effort)-Nasua nasua               0.3370 0.2468 -0.1361  0.3330  0.8521
scale(effort)-Panthera onca             0.1712 0.1734 -0.1568  0.1688  0.5259
scale(effort)-Pecari tajacu             0.3633 0.1082  0.1646  0.3561  0.5827
scale(effort)-Priodontes maximus        0.0704 0.1981 -0.3297  0.0723  0.4445
scale(effort)-Procyon cancrivorus       0.2285 0.2270 -0.2249  0.2271  0.6608
scale(effort)-Puma concolor             0.3360 0.1611  0.0466  0.3255  0.6707
scale(effort)-Speothos venaticus        0.2139 0.2483 -0.2982  0.2171  0.6866
scale(effort)-Tamandua tetradactyla     0.2185 0.2465 -0.2789  0.2221  0.6886
scale(effort)-Tapirus terrestris        0.3511 0.1189  0.1263  0.3488  0.5905
scale(effort)-Tayassu pecari            0.4974 0.1711  0.1927  0.4848  0.8689
                                         Rhat  ESS
(Intercept)-Atelocynus microtis        1.0401  298
(Intercept)-Coendou sp                 1.0078  272
(Intercept)-Cuniculus paca             1.0002 3088
(Intercept)-Dasyprocta fuliginosa      1.0030 3000
(Intercept)-Dasypus novemcinctus       1.0035 1778
(Intercept)-Didelphis sp               1.0068  171
(Intercept)-Eira barbara               1.0194  312
(Intercept)-Herpailurus yagouaroundi   1.0677  264
(Intercept)-Leopardus pardalis         1.0131 1453
(Intercept)-Leopardus tigrinus         1.0000 1704
(Intercept)-Leopardus wiedii           1.0026  278
(Intercept)-Mazama murelia             1.0140  938
(Intercept)-Mazama zamora              1.0041 1504
(Intercept)-Myoprocta pratti           1.0006 2786
(Intercept)-Myrmecophaga tridactyla    1.0154  338
(Intercept)-Nasua nasua                1.0164  189
(Intercept)-Panthera onca              1.0046  537
(Intercept)-Pecari tajacu              1.0025 2105
(Intercept)-Priodontes maximus         1.0363  275
(Intercept)-Procyon cancrivorus        1.0123 1009
(Intercept)-Puma concolor              1.0005 2661
(Intercept)-Speothos venaticus         1.0452  201
(Intercept)-Tamandua tetradactyla      1.0219  237
(Intercept)-Tapirus terrestris         1.0030 2630
(Intercept)-Tayassu pecari             1.0003 2160
scale(effort)-Atelocynus microtis      1.0017 3000
scale(effort)-Coendou sp               0.9996 3000
scale(effort)-Cuniculus paca           1.0054 3522
scale(effort)-Dasyprocta fuliginosa    1.0014 2844
scale(effort)-Dasypus novemcinctus     1.0026 3000
scale(effort)-Didelphis sp             1.0006 3074
scale(effort)-Eira barbara             1.0069 3000
scale(effort)-Herpailurus yagouaroundi 1.0002 2837
scale(effort)-Leopardus pardalis       1.0012 3000
scale(effort)-Leopardus tigrinus       1.0003 3000
scale(effort)-Leopardus wiedii         1.0014 3000
scale(effort)-Mazama murelia           1.0080 2731
scale(effort)-Mazama zamora            1.0016 3000
scale(effort)-Myoprocta pratti         1.0074 2684
scale(effort)-Myrmecophaga tridactyla  1.0075 2738
scale(effort)-Nasua nasua              1.0001 3000
scale(effort)-Panthera onca            1.0050 3000
scale(effort)-Pecari tajacu            1.0002 3064
scale(effort)-Priodontes maximus       1.0001 2627
scale(effort)-Procyon cancrivorus      1.0017 3000
scale(effort)-Puma concolor            1.0062 3000
scale(effort)-Speothos venaticus       1.0022 3000
scale(effort)-Tamandua tetradactyla    1.0014 3000
scale(effort)-Tapirus terrestris       1.0078 2540
scale(effort)-Tayassu pecari           1.0037 3000

----------------------------------------
    Spatial Covariance
----------------------------------------
         Mean     SD   2.5%     50%   97.5%   Rhat  ESS
phi-1 13.7269 8.0014 0.6750 13.9028 26.6418 1.0007 2843
phi-2 13.7322 7.9105 0.7179 13.6774 26.8470 1.0049 3000
phi-3 13.4748 8.0759 0.4572 13.0370 26.9249 1.0008 2609
phi-4 13.6439 7.9863 0.5321 13.5390 26.8039 1.0014 2827
phi-5 13.5677 8.0831 0.6575 13.5918 26.8284 1.0028 3000
Code
summary(out.sp, level = 'both')

Call:
sfMsPGOcc(occ.formula = ~scale(elev) + scale(border_dist) + scale(FLII), 
    det.formula = ~scale(effort), data = data_list, cov.model = "exponential", 
    NNGP = TRUE, n.neighbors = 15, n.factors = 5, n.batch = 600, 
    batch.length = 25, n.omp.threads = 6, n.report = 1000, n.burn = 5000, 
    n.thin = 10, n.chains = 3)

Samples per Chain: 15000
Burn-in: 5000
Thinning Rate: 10
Number of Chains: 3
Total Posterior Samples: 3000
Run Time (min): 10.6275

----------------------------------------
    Community Level
----------------------------------------
Occurrence Means (logit scale): 
                      Mean     SD    2.5%     50%   97.5%   Rhat ESS
(Intercept)        -1.9004 0.5780 -3.0373 -1.9005 -0.7742 1.0117 252
scale(elev)        -0.3026 0.2473 -0.7818 -0.3017  0.1768 1.0123 915
scale(border_dist) -0.8487 0.2246 -1.2976 -0.8398 -0.4210 1.0113 667
scale(FLII)         0.0366 0.2443 -0.4179  0.0220  0.5447 1.0238 915

Occurrence Variances (logit scale): 
                     Mean     SD   2.5%    50%   97.5%   Rhat  ESS
(Intercept)        6.5946 2.7326 2.8517 6.1052 13.0779 1.0046  430
scale(elev)        0.3012 0.2088 0.0574 0.2514  0.8286 1.0162 1148
scale(border_dist) 0.1369 0.1078 0.0275 0.1051  0.4098 1.0052 1789
scale(FLII)        0.6414 0.4785 0.1017 0.5174  1.8928 1.0109  804

Detection Means (logit scale): 
                 Mean     SD   2.5%     50%   97.5%   Rhat  ESS
(Intercept)   -2.0014 0.3122 -2.651 -1.9877 -1.4357 1.0316  250
scale(effort)  0.3091 0.0812  0.150  0.3070  0.4742 0.9998 2683

Detection Variances (logit scale): 
                Mean     SD   2.5%    50%  97.5%   Rhat  ESS
(Intercept)   1.5312 0.7843 0.5186 1.3647 3.5614 1.0183  118
scale(effort) 0.0615 0.0364 0.0200 0.0526 0.1530 1.0051 2660

----------------------------------------
    Species Level
----------------------------------------
Occurrence (logit scale): 
                                               Mean     SD    2.5%     50%
(Intercept)-Atelocynus microtis             -2.5128 1.3030 -4.2470 -2.7335
(Intercept)-Coendou sp                      -3.9762 1.7049 -6.9045 -4.1516
(Intercept)-Cuniculus paca                   0.1870 0.2871 -0.3508  0.1811
(Intercept)-Dasyprocta fuliginosa            0.2738 0.3517 -0.3876  0.2628
(Intercept)-Dasypus novemcinctus            -2.0688 0.6222 -3.4132 -2.0190
(Intercept)-Didelphis sp                    -4.2873 2.0842 -7.7730 -4.5076
(Intercept)-Eira barbara                    -3.7574 1.3940 -6.3749 -3.8243
(Intercept)-Herpailurus yagouaroundi        -1.9744 1.6957 -5.0297 -2.0878
(Intercept)-Leopardus pardalis              -2.0684 0.6689 -3.3723 -2.0609
(Intercept)-Leopardus tigrinus              -6.0705 1.2850 -8.7898 -5.9842
(Intercept)-Leopardus wiedii                -4.1753 1.4582 -6.9157 -4.2085
(Intercept)-Mazama murelia                  -0.5998 0.7635 -1.9557 -0.6517
(Intercept)-Mazama zamora                    1.7925 0.5106  0.9311  1.7438
(Intercept)-Myoprocta pratti                -3.8449 0.7404 -5.4724 -3.7841
(Intercept)-Myrmecophaga tridactyla         -1.6157 1.3187 -3.9155 -1.6979
(Intercept)-Nasua nasua                     -4.0631 1.6847 -7.1178 -4.2048
(Intercept)-Panthera onca                   -0.8588 0.9750 -2.5945 -0.9424
(Intercept)-Pecari tajacu                    1.7134 0.5536  0.8385  1.6424
(Intercept)-Priodontes maximus              -0.1326 1.6703 -2.8466 -0.3335
(Intercept)-Procyon cancrivorus             -3.9133 1.0701 -6.1357 -3.8848
(Intercept)-Puma concolor                   -1.8649 0.5259 -3.0144 -1.8428
(Intercept)-Speothos venaticus              -4.2986 1.9431 -7.8873 -4.4031
(Intercept)-Tamandua tetradactyla           -4.3434 1.6741 -7.2208 -4.5284
(Intercept)-Tapirus terrestris               0.9599 0.4889  0.1531  0.9020
(Intercept)-Tayassu pecari                  -0.4809 0.4429 -1.3248 -0.4893
scale(elev)-Atelocynus microtis             -0.4737 0.4916 -1.4352 -0.4755
scale(elev)-Coendou sp                      -0.4648 0.5374 -1.5933 -0.4436
scale(elev)-Cuniculus paca                  -0.3584 0.3405 -1.0283 -0.3596
scale(elev)-Dasyprocta fuliginosa            0.1427 0.4049 -0.6018  0.1329
scale(elev)-Dasypus novemcinctus            -0.3089 0.4063 -1.0970 -0.3108
scale(elev)-Didelphis sp                    -0.1234 0.5432 -1.1716 -0.1300
scale(elev)-Eira barbara                    -0.3241 0.5036 -1.2994 -0.3176
scale(elev)-Herpailurus yagouaroundi        -0.3332 0.5282 -1.3915 -0.3369
scale(elev)-Leopardus pardalis              -0.3590 0.4296 -1.1894 -0.3689
scale(elev)-Leopardus tigrinus              -0.5066 0.5458 -1.6443 -0.4849
scale(elev)-Leopardus wiedii                -0.1668 0.5010 -1.1384 -0.1912
scale(elev)-Mazama murelia                  -0.5848 0.4503 -1.4943 -0.5733
scale(elev)-Mazama zamora                   -0.0811 0.4324 -0.8885 -0.1022
scale(elev)-Myoprocta pratti                -0.2542 0.4240 -1.0929 -0.2532
scale(elev)-Myrmecophaga tridactyla         -0.3651 0.5071 -1.3814 -0.3689
scale(elev)-Nasua nasua                     -0.5416 0.5578 -1.7241 -0.5147
scale(elev)-Panthera onca                   -0.3542 0.4677 -1.2756 -0.3528
scale(elev)-Pecari tajacu                   -0.4186 0.4285 -1.2528 -0.4325
scale(elev)-Priodontes maximus              -0.3171 0.5253 -1.3301 -0.3326
scale(elev)-Procyon cancrivorus              0.0140 0.4911 -0.8936 -0.0129
scale(elev)-Puma concolor                   -1.0840 0.4727 -2.0723 -1.0631
scale(elev)-Speothos venaticus              -0.4682 0.5558 -1.5677 -0.4544
scale(elev)-Tamandua tetradactyla           -0.2614 0.5054 -1.2328 -0.2749
scale(elev)-Tapirus terrestris              -0.0707 0.4335 -0.8511 -0.0876
scale(elev)-Tayassu pecari                   0.4808 0.4725 -0.3824  0.4538
scale(border_dist)-Atelocynus microtis      -0.6828 0.3904 -1.4292 -0.6927
scale(border_dist)-Coendou sp               -0.7873 0.4206 -1.6252 -0.7901
scale(border_dist)-Cuniculus paca           -0.8343 0.3092 -1.4602 -0.8327
scale(border_dist)-Dasyprocta fuliginosa    -0.9597 0.3458 -1.6666 -0.9450
scale(border_dist)-Dasypus novemcinctus     -0.6013 0.3597 -1.2652 -0.6165
scale(border_dist)-Didelphis sp             -0.9018 0.4135 -1.7471 -0.8808
scale(border_dist)-Eira barbara             -0.7756 0.4022 -1.5474 -0.7793
scale(border_dist)-Herpailurus yagouaroundi -0.8359 0.4126 -1.6615 -0.8410
scale(border_dist)-Leopardus pardalis       -0.8647 0.3666 -1.5620 -0.8684
scale(border_dist)-Leopardus tigrinus       -0.7717 0.4101 -1.5623 -0.7772
scale(border_dist)-Leopardus wiedii         -0.8336 0.3910 -1.6125 -0.8316
scale(border_dist)-Mazama murelia           -0.7455 0.3734 -1.4664 -0.7487
scale(border_dist)-Mazama zamora            -0.9256 0.3338 -1.5856 -0.9125
scale(border_dist)-Myoprocta pratti         -0.9819 0.3812 -1.7840 -0.9648
scale(border_dist)-Myrmecophaga tridactyla  -0.9126 0.3916 -1.7340 -0.8963
scale(border_dist)-Nasua nasua              -0.8221 0.4291 -1.6939 -0.8266
scale(border_dist)-Panthera onca            -1.0082 0.3920 -1.8357 -0.9932
scale(border_dist)-Pecari tajacu            -0.8686 0.3469 -1.5899 -0.8577
scale(border_dist)-Priodontes maximus       -0.8037 0.4097 -1.6193 -0.8029
scale(border_dist)-Procyon cancrivorus      -0.9930 0.4051 -1.8558 -0.9753
scale(border_dist)-Puma concolor            -0.7343 0.3518 -1.4148 -0.7384
scale(border_dist)-Speothos venaticus       -0.7537 0.4195 -1.5706 -0.7587
scale(border_dist)-Tamandua tetradactyla    -0.8058 0.3967 -1.5666 -0.8049
scale(border_dist)-Tapirus terrestris       -0.9506 0.3504 -1.6711 -0.9357
scale(border_dist)-Tayassu pecari           -1.0954 0.3808 -1.9312 -1.0723
scale(FLII)-Atelocynus microtis             -0.5822 0.4303 -1.5873 -0.5403
scale(FLII)-Coendou sp                       0.2433 0.7441 -1.1468  0.1913
scale(FLII)-Cuniculus paca                  -0.5901 0.3702 -1.4146 -0.5548
scale(FLII)-Dasyprocta fuliginosa           -0.7084 0.4406 -1.6551 -0.6645
scale(FLII)-Dasypus novemcinctus            -0.6336 0.4623 -1.7114 -0.5728
scale(FLII)-Didelphis sp                     0.2202 0.7862 -1.2759  0.1918
scale(FLII)-Eira barbara                     0.0436 0.6483 -1.2252  0.0300
scale(FLII)-Herpailurus yagouaroundi        -0.0460 0.7452 -1.6217 -0.0418
scale(FLII)-Leopardus pardalis               0.4831 0.5475 -0.4671  0.4366
scale(FLII)-Leopardus tigrinus               0.2894 0.6830 -0.8272  0.2082
scale(FLII)-Leopardus wiedii                -0.0673 0.6794 -1.5194 -0.0411
scale(FLII)-Mazama murelia                  -0.0856 0.4245 -0.9453 -0.0700
scale(FLII)-Mazama zamora                   -0.5200 0.4830 -1.6106 -0.4682
scale(FLII)-Myoprocta pratti                 0.2775 0.5018 -0.5905  0.2323
scale(FLII)-Myrmecophaga tridactyla          0.2257 0.6762 -1.0848  0.2200
scale(FLII)-Nasua nasua                      0.2968 0.7568 -1.0586  0.2254
scale(FLII)-Panthera onca                    0.7468 0.6968 -0.4501  0.6853
scale(FLII)-Pecari tajacu                   -0.2823 0.4112 -1.1886 -0.2508
scale(FLII)-Priodontes maximus               0.2659 0.7464 -1.1339  0.2174
scale(FLII)-Procyon cancrivorus             -0.7344 0.5369 -1.9682 -0.6613
scale(FLII)-Puma concolor                    1.1210 0.7357 -0.0587  1.0392
scale(FLII)-Speothos venaticus               0.1914 0.7821 -1.2241  0.1237
scale(FLII)-Tamandua tetradactyla            0.2533 0.6923 -0.9948  0.1895
scale(FLII)-Tapirus terrestris              -0.1850 0.3755 -0.9681 -0.1673
scale(FLII)-Tayassu pecari                   0.7364 0.5095 -0.2023  0.7009
                                              97.5%   Rhat  ESS
(Intercept)-Atelocynus microtis              0.9057 1.0699  168
(Intercept)-Coendou sp                      -0.0131 1.0107  133
(Intercept)-Cuniculus paca                   0.7849 1.0005 2379
(Intercept)-Dasyprocta fuliginosa            0.9908 1.0000 2935
(Intercept)-Dasypus novemcinctus            -0.9040 1.0034 1038
(Intercept)-Didelphis sp                     0.8428 1.0649  111
(Intercept)-Eira barbara                    -0.7099 1.0580  276
(Intercept)-Herpailurus yagouaroundi         1.8817 1.1131  185
(Intercept)-Leopardus pardalis              -0.7518 1.0106  978
(Intercept)-Leopardus tigrinus              -3.7877 1.0057  697
(Intercept)-Leopardus wiedii                -1.1875 1.0046  178
(Intercept)-Mazama murelia                   1.1361 1.0168  633
(Intercept)-Mazama zamora                    2.9254 1.0034 1539
(Intercept)-Myoprocta pratti                -2.5805 1.0051 1123
(Intercept)-Myrmecophaga tridactyla          1.3455 1.0430  252
(Intercept)-Nasua nasua                     -0.3296 1.0141  165
(Intercept)-Panthera onca                    1.3283 1.0043  427
(Intercept)-Pecari tajacu                    3.0087 1.0060 1390
(Intercept)-Priodontes maximus               3.7599 1.0732  195
(Intercept)-Procyon cancrivorus             -1.8585 1.0316  640
(Intercept)-Puma concolor                   -0.9251 1.0021 1597
(Intercept)-Speothos venaticus              -0.3298 1.0562  156
(Intercept)-Tamandua tetradactyla           -0.3395 1.0428  223
(Intercept)-Tapirus terrestris               2.1000 1.0086 1512
(Intercept)-Tayassu pecari                   0.4260 1.0006 1809
scale(elev)-Atelocynus microtis              0.4951 1.0043 1564
scale(elev)-Coendou sp                       0.5385 1.0143 1282
scale(elev)-Cuniculus paca                   0.3111 1.0096 1398
scale(elev)-Dasyprocta fuliginosa            0.9748 1.0041 1294
scale(elev)-Dasypus novemcinctus             0.4791 1.0005 1946
scale(elev)-Didelphis sp                     1.0063 1.0096 1587
scale(elev)-Eira barbara                     0.6523 1.0048 1500
scale(elev)-Herpailurus yagouaroundi         0.7446 1.0101 1433
scale(elev)-Leopardus pardalis               0.4853 1.0052 1510
scale(elev)-Leopardus tigrinus               0.5245 1.0074 1799
scale(elev)-Leopardus wiedii                 0.8687 1.0129 1580
scale(elev)-Mazama murelia                   0.2666 1.0008 1550
scale(elev)-Mazama zamora                    0.8440 1.0118 1741
scale(elev)-Myoprocta pratti                 0.5643 1.0004 1802
scale(elev)-Myrmecophaga tridactyla          0.6118 1.0084 1239
scale(elev)-Nasua nasua                      0.4557 1.0045 1403
scale(elev)-Panthera onca                    0.5669 1.0074 1660
scale(elev)-Pecari tajacu                    0.4392 1.0035 1783
scale(elev)-Priodontes maximus               0.7670 1.0126 1494
scale(elev)-Procyon cancrivorus              1.0490 1.0030 1800
scale(elev)-Puma concolor                   -0.2185 1.0001 1573
scale(elev)-Speothos venaticus               0.5765 1.0039 1441
scale(elev)-Tamandua tetradactyla            0.7672 1.0006 1454
scale(elev)-Tapirus terrestris               0.8665 1.0161 1644
scale(elev)-Tayassu pecari                   1.5357 1.0087 1117
scale(border_dist)-Atelocynus microtis       0.1190 1.0047 1211
scale(border_dist)-Coendou sp                0.0695 1.0078 1480
scale(border_dist)-Cuniculus paca           -0.2372 1.0189 1349
scale(border_dist)-Dasyprocta fuliginosa    -0.3054 1.0107 1427
scale(border_dist)-Dasypus novemcinctus      0.1536 1.0030 1567
scale(border_dist)-Didelphis sp             -0.1091 1.0007 1518
scale(border_dist)-Eira barbara              0.0307 1.0028 1637
scale(border_dist)-Herpailurus yagouaroundi -0.0069 1.0002 1296
scale(border_dist)-Leopardus pardalis       -0.1439 1.0063 1462
scale(border_dist)-Leopardus tigrinus        0.0353 1.0057 1365
scale(border_dist)-Leopardus wiedii         -0.0501 1.0004 1306
scale(border_dist)-Mazama murelia           -0.0088 1.0010 1664
scale(border_dist)-Mazama zamora            -0.3030 1.0159 1442
scale(border_dist)-Myoprocta pratti         -0.2671 1.0008 1302
scale(border_dist)-Myrmecophaga tridactyla  -0.1750 1.0011 1406
scale(border_dist)-Nasua nasua               0.0470 1.0015 1351
scale(border_dist)-Panthera onca            -0.2805 1.0037 1481
scale(border_dist)-Pecari tajacu            -0.1899 1.0152 1414
scale(border_dist)-Priodontes maximus        0.0492 1.0029 1372
scale(border_dist)-Procyon cancrivorus      -0.2398 1.0021 1491
scale(border_dist)-Puma concolor            -0.0398 1.0034 1527
scale(border_dist)-Speothos venaticus        0.1245 1.0077 1428
scale(border_dist)-Tamandua tetradactyla     0.0005 1.0095 1420
scale(border_dist)-Tapirus terrestris       -0.2964 1.0091 1380
scale(border_dist)-Tayassu pecari           -0.3936 1.0200 1456
scale(FLII)-Atelocynus microtis              0.1792 1.0019 1939
scale(FLII)-Coendou sp                       1.8244 1.0065 1180
scale(FLII)-Cuniculus paca                   0.0244 1.0078 1509
scale(FLII)-Dasyprocta fuliginosa            0.0643 1.0199 2318
scale(FLII)-Dasypus novemcinctus             0.1033 1.0037 1772
scale(FLII)-Didelphis sp                     1.9119 1.0118 1160
scale(FLII)-Eira barbara                     1.3484 1.0097 1687
scale(FLII)-Herpailurus yagouaroundi         1.4892 1.0260 1262
scale(FLII)-Leopardus pardalis               1.6661 1.0006 1781
scale(FLII)-Leopardus tigrinus               1.8227 1.0002 1558
scale(FLII)-Leopardus wiedii                 1.2383 1.0193 1021
scale(FLII)-Mazama murelia                   0.7201 1.0047 2158
scale(FLII)-Mazama zamora                    0.2747 1.0179 1909
scale(FLII)-Myoprocta pratti                 1.3658 1.0022 1972
scale(FLII)-Myrmecophaga tridactyla          1.5975 1.0014 1137
scale(FLII)-Nasua nasua                      1.9858 1.0153 1256
scale(FLII)-Panthera onca                    2.3258 1.0076 1131
scale(FLII)-Pecari tajacu                    0.4494 1.0149 2245
scale(FLII)-Priodontes maximus               1.8764 1.0047 1082
scale(FLII)-Procyon cancrivorus              0.1262 1.0281 1893
scale(FLII)-Puma concolor                    2.7303 1.0028  962
scale(FLII)-Speothos venaticus               1.9324 1.0075 1258
scale(FLII)-Tamandua tetradactyla            1.8139 1.0142 1411
scale(FLII)-Tapirus terrestris               0.5039 1.0138 2579
scale(FLII)-Tayassu pecari                   1.8270 1.0022 1445

Detection (logit scale): 
                                          Mean     SD    2.5%     50%   97.5%
(Intercept)-Atelocynus microtis        -2.6640 0.7999 -4.5022 -2.5970 -1.2942
(Intercept)-Coendou sp                 -3.1213 1.2292 -5.6345 -3.0436 -0.9605
(Intercept)-Cuniculus paca             -0.4806 0.1152 -0.7069 -0.4816 -0.2554
(Intercept)-Dasyprocta fuliginosa      -0.4248 0.1084 -0.6379 -0.4248 -0.2151
(Intercept)-Dasypus novemcinctus       -1.5136 0.2979 -2.1107 -1.5065 -0.9523
(Intercept)-Didelphis sp               -3.3004 1.2734 -5.9456 -3.2340 -1.0734
(Intercept)-Eira barbara               -2.6661 0.7242 -4.1821 -2.6241 -1.3653
(Intercept)-Herpailurus yagouaroundi   -3.4650 0.7675 -4.9060 -3.4801 -1.9549
(Intercept)-Leopardus pardalis         -1.6917 0.2726 -2.2718 -1.6857 -1.1822
(Intercept)-Leopardus tigrinus         -1.1396 0.9360 -3.0844 -1.0886  0.5774
(Intercept)-Leopardus wiedii           -2.6587 0.8582 -4.4724 -2.6035 -1.1289
(Intercept)-Mazama murelia             -1.9624 0.2870 -2.5581 -1.9539 -1.4265
(Intercept)-Mazama zamora              -0.8281 0.1063 -1.0403 -0.8248 -0.6231
(Intercept)-Myoprocta pratti           -0.9037 0.3046 -1.5301 -0.8901 -0.3558
(Intercept)-Myrmecophaga tridactyla    -2.8685 0.5125 -3.9003 -2.8584 -1.8662
(Intercept)-Nasua nasua                -3.1380 1.0257 -5.2303 -3.0960 -1.2575
(Intercept)-Panthera onca              -2.4220 0.3707 -3.1502 -2.4132 -1.7266
(Intercept)-Pecari tajacu              -0.9121 0.1124 -1.1307 -0.9122 -0.7039
(Intercept)-Priodontes maximus         -3.2774 0.5092 -4.2182 -3.2985 -2.2419
(Intercept)-Procyon cancrivorus        -2.1652 0.5989 -3.3968 -2.1425 -1.0957
(Intercept)-Puma concolor              -1.3238 0.2195 -1.7619 -1.3225 -0.9137
(Intercept)-Speothos venaticus         -3.2914 1.2116 -5.5791 -3.2835 -1.0536
(Intercept)-Tamandua tetradactyla      -2.6054 1.0292 -4.9165 -2.5023 -0.8333
(Intercept)-Tapirus terrestris         -1.0407 0.1320 -1.3054 -1.0399 -0.7991
(Intercept)-Tayassu pecari             -1.4252 0.1875 -1.7961 -1.4265 -1.0596
scale(effort)-Atelocynus microtis       0.3561 0.2369 -0.0983  0.3504  0.8301
scale(effort)-Coendou sp                0.3192 0.2536 -0.1936  0.3218  0.8377
scale(effort)-Cuniculus paca            0.3441 0.1106  0.1318  0.3421  0.5694
scale(effort)-Dasyprocta fuliginosa     0.3194 0.1027  0.1299  0.3171  0.5282
scale(effort)-Dasypus novemcinctus      0.3068 0.1752 -0.0191  0.2993  0.6669
scale(effort)-Didelphis sp              0.3158 0.2521 -0.1678  0.3163  0.8139
scale(effort)-Eira barbara              0.3912 0.2400 -0.0483  0.3789  0.9177
scale(effort)-Herpailurus yagouaroundi  0.1573 0.2311 -0.3157  0.1649  0.6086
scale(effort)-Leopardus pardalis        0.1759 0.1652 -0.1429  0.1729  0.5081
scale(effort)-Leopardus tigrinus        0.3663 0.2540 -0.1170  0.3596  0.8946
scale(effort)-Leopardus wiedii          0.3468 0.2438 -0.1115  0.3388  0.8527
scale(effort)-Mazama murelia            0.5080 0.1977  0.1633  0.4925  0.9449
scale(effort)-Mazama zamora             0.3904 0.1067  0.1972  0.3866  0.6126
scale(effort)-Myoprocta pratti          0.2838 0.2008 -0.1012  0.2820  0.6847
scale(effort)-Myrmecophaga tridactyla   0.3333 0.2119 -0.0758  0.3267  0.7775
scale(effort)-Nasua nasua               0.3370 0.2468 -0.1361  0.3330  0.8521
scale(effort)-Panthera onca             0.1712 0.1734 -0.1568  0.1688  0.5259
scale(effort)-Pecari tajacu             0.3633 0.1082  0.1646  0.3561  0.5827
scale(effort)-Priodontes maximus        0.0704 0.1981 -0.3297  0.0723  0.4445
scale(effort)-Procyon cancrivorus       0.2285 0.2270 -0.2249  0.2271  0.6608
scale(effort)-Puma concolor             0.3360 0.1611  0.0466  0.3255  0.6707
scale(effort)-Speothos venaticus        0.2139 0.2483 -0.2982  0.2171  0.6866
scale(effort)-Tamandua tetradactyla     0.2185 0.2465 -0.2789  0.2221  0.6886
scale(effort)-Tapirus terrestris        0.3511 0.1189  0.1263  0.3488  0.5905
scale(effort)-Tayassu pecari            0.4974 0.1711  0.1927  0.4848  0.8689
                                         Rhat  ESS
(Intercept)-Atelocynus microtis        1.0401  298
(Intercept)-Coendou sp                 1.0078  272
(Intercept)-Cuniculus paca             1.0002 3088
(Intercept)-Dasyprocta fuliginosa      1.0030 3000
(Intercept)-Dasypus novemcinctus       1.0035 1778
(Intercept)-Didelphis sp               1.0068  171
(Intercept)-Eira barbara               1.0194  312
(Intercept)-Herpailurus yagouaroundi   1.0677  264
(Intercept)-Leopardus pardalis         1.0131 1453
(Intercept)-Leopardus tigrinus         1.0000 1704
(Intercept)-Leopardus wiedii           1.0026  278
(Intercept)-Mazama murelia             1.0140  938
(Intercept)-Mazama zamora              1.0041 1504
(Intercept)-Myoprocta pratti           1.0006 2786
(Intercept)-Myrmecophaga tridactyla    1.0154  338
(Intercept)-Nasua nasua                1.0164  189
(Intercept)-Panthera onca              1.0046  537
(Intercept)-Pecari tajacu              1.0025 2105
(Intercept)-Priodontes maximus         1.0363  275
(Intercept)-Procyon cancrivorus        1.0123 1009
(Intercept)-Puma concolor              1.0005 2661
(Intercept)-Speothos venaticus         1.0452  201
(Intercept)-Tamandua tetradactyla      1.0219  237
(Intercept)-Tapirus terrestris         1.0030 2630
(Intercept)-Tayassu pecari             1.0003 2160
scale(effort)-Atelocynus microtis      1.0017 3000
scale(effort)-Coendou sp               0.9996 3000
scale(effort)-Cuniculus paca           1.0054 3522
scale(effort)-Dasyprocta fuliginosa    1.0014 2844
scale(effort)-Dasypus novemcinctus     1.0026 3000
scale(effort)-Didelphis sp             1.0006 3074
scale(effort)-Eira barbara             1.0069 3000
scale(effort)-Herpailurus yagouaroundi 1.0002 2837
scale(effort)-Leopardus pardalis       1.0012 3000
scale(effort)-Leopardus tigrinus       1.0003 3000
scale(effort)-Leopardus wiedii         1.0014 3000
scale(effort)-Mazama murelia           1.0080 2731
scale(effort)-Mazama zamora            1.0016 3000
scale(effort)-Myoprocta pratti         1.0074 2684
scale(effort)-Myrmecophaga tridactyla  1.0075 2738
scale(effort)-Nasua nasua              1.0001 3000
scale(effort)-Panthera onca            1.0050 3000
scale(effort)-Pecari tajacu            1.0002 3064
scale(effort)-Priodontes maximus       1.0001 2627
scale(effort)-Procyon cancrivorus      1.0017 3000
scale(effort)-Puma concolor            1.0062 3000
scale(effort)-Speothos venaticus       1.0022 3000
scale(effort)-Tamandua tetradactyla    1.0014 3000
scale(effort)-Tapirus terrestris       1.0078 2540
scale(effort)-Tayassu pecari           1.0037 3000

----------------------------------------
    Spatial Covariance
----------------------------------------
         Mean     SD   2.5%     50%   97.5%   Rhat  ESS
phi-1 13.7269 8.0014 0.6750 13.9028 26.6418 1.0007 2843
phi-2 13.7322 7.9105 0.7179 13.6774 26.8470 1.0049 3000
phi-3 13.4748 8.0759 0.4572 13.0370 26.9249 1.0008 2609
phi-4 13.6439 7.9863 0.5321 13.5390 26.8039 1.0014 2827
phi-5 13.5677 8.0831 0.6575 13.5918 26.8284 1.0028 3000

Bayesian p-values can be inspected to check for lack of fit (overall or by species). Lack of fit at significance level = 0.05 is indicated by Bayesian p-values below 0.025 or greater than 0.975. The overall Bayesian p-value (Bpvalue) indicates no problems with lack of fit. Likewise, species-level Bayesian p-values (Bpvalue_species) indicate no lack of fit for any species.

Gelman and Rubin’s convergence diagnostic: Approximate convergence is diagnosed when the upper limit is close to 1.

Convergence is diagnosed when the chains have ‘forgotten’ their initial values, and the output from all chains is indistinguishable. The gelman.diag diagnostic is applied to a single variable from the chain. It is based a comparison of within-chain and between-chain variances, and is similar to a classical analysis of variance.

Values substantially above 1 indicate lack of convergence.

Model Diagnostics

Code
#| eval: true
#| echo: true
#| code-fold: true
#| warning: false
#| message: false
# Extract posterior draws for later use
posterior1 <- as.array(out.sp)

# Trace plots to check chain mixing. Extract posterior samples and bind in a single matrix.
POSTERIOR.MATRIX <- cbind(out.sp$alpha.comm.samples, 
                          out.sp$beta.comm.samples,  
                          out.sp$alpha.samples, 
                          out.sp$beta.samples)

# Matrix output is all chains combined, split into 3 chains.
CHAIN.1 <- as.mcmc(POSTERIOR.MATRIX[1:1000,])
CHAIN.2 <- as.mcmc(POSTERIOR.MATRIX[1001:2000,])
CHAIN.3 <- as.mcmc(POSTERIOR.MATRIX[2001:3000,])
# CHAIN.4 <- as.mcmc(POSTERIOR.MATRIX[8001:10000,])

# Bind four chains as coda mcmc.list object.
POSTERIOR.CHAINS <- mcmc.list(CHAIN.1, CHAIN.2, CHAIN.3)#, CHAIN.4)

# Create an empty folder.
# dir.create ("Beetle_plots")

# Plot chain mixing of each parameter to a multi-panel plot and save to the new folder. ART 5 mins

######################################
#### SAVE Diagnostics at PDF
# MCMCtrace(POSTERIOR.CHAINS, params = "all", Rhat = TRUE, n.eff = TRUE)#, pdf = TRUE, filename = "Beetle_240909_traceplots.pdf", wd = "Beetle_plots")



#mcmc_trace(fit.commu, parms = c("beta.ranef.cont.border_dist.mean"))

#posterior2 <- extract(fit.commu, inc_warmup = TRUE, permuted = FALSE)

#color_scheme_set("mix-blue-pink")
#p <- mcmc_trace(posterior1,  pars = c("mu", "tau"), n_warmup = 300,
#                facet_args = list(nrow = 2, labeller = label_parsed))
#p + facet_text(size = 15)



#outMCMC <- fit.commu #Convert output to MCMC object
#diagnostics chains 

# all as pdf
# MCMCtrace(outMCMC)

# MCMCtrace(outMCMC, params = c("alpha0"), type = 'trace', Rhat = TRUE, n.eff = TRUE)

# MCMCtrace(outMCMC, params = c("beta0"), type = 'trace', Rhat = TRUE, n.eff = TRUE)

# MCMCtrace(outMCMC, params = c("beta.ranef.cont.border_dist"), type = 'trace', Rhat = TRUE, n.eff = TRUE)

# MCMCtrace(out.sp, params = c("beta.ranef.cont.border_dist.mean"), type = 'trace', pdf = F, Rhat = TRUE, n.eff = TRUE)

# MCMCtrace(outMCMC, params = c("beta.ranef.cont.elev"), type = 'trace', Rhat = TRUE, n.eff = TRUE)

# MCMCtrace(outMCMC, params = c("beta.ranef.cont.elev.mean"), type = 'trace', pdf = F, Rhat = TRUE, n.eff = TRUE)


### density
# MCMCtrace(outMCMC, params = c("Nspecies"), ISB = FALSE, pdf = F, exact = TRUE, post_zm = TRUE, type = 'density', Rhat = TRUE, n.eff = TRUE, ind = TRUE)

### density
# MCMCtrace(outMCMC, params = c("beta.ranef.cont.elev.mean"), ISB = FALSE, pdf = F, exact = TRUE, post_zm = TRUE, type = 'density', Rhat = TRUE, n.eff = TRUE, ind = TRUE)

### density
#MCMCtrace(outMCMC, params = c("beta.ranef.cont.border_dist.mean"), ISB = FALSE, pdf = F, exact = TRUE, post_zm = TRUE, type = 'density', Rhat = TRUE, n.eff = TRUE, ind = TRUE)

#coda::gelman.diag(outMCMC,  multivariate = FALSE, transform=FALSE)
                    
# coda::gelman.plot(outMCMC,  multivariate = FALSE)



# 
# mcmc_intervals(outMCMC, pars = c("Nspecies_in_AP[1]",
#                                  "Nspecies_in_AP[2]"),
#                point_est = "mean",
#                prob = 0.75, prob_outer = 0.95) +
#   ggtitle("Number of species") + 
#   scale_y_discrete(labels = c("Nspecies_in_AP[1]"=levels(sitecovs$in_AP)[1],
#              "Nspecies_in_AP[2]"=levels(sitecovs$in_AP)[2]))
# 
# #Continuous
# p <- mcmc_intervals(outMCMC, 
#                pars = c("beta.ranef.cont.border_dist.mean",
#                          #"beta.ranef.cont.elev.mean",
#                         "beta.ranef.categ.in_AP.mean[2]"))
# 
# # relabel parameters
# p + scale_y_discrete(
#   labels = c("beta.ranef.cont.border_dist.mean"="Dist_border",
#                          #"beta.ranef.cont.elev.mean"="Elevation",
#                         "beta.ranef.categ.in_AP.mean[2]"="in_AP")
# ) +
#   ggtitle("Treatment effect on all species")
# 

Posterior Summary (effect)

Community effects

Code
# Create simple plot summaries using MCMCvis package.
# Detection covariate effects --------- 
MCMCplot(out.sp$alpha.comm.samples, ref_ovl = TRUE, ci = c(50, 95))
# Occupancy community-level effects 
MCMCplot(out.sp$beta.comm.samples, ref_ovl = TRUE, ci = c(50, 95))
(a) Detection
(b) Occupancy
Figure 1: Community effects

Species effects

Code
# Occupancy species-level effects 
MCMCplot(out.sp$beta.samples[,26:50], ref_ovl = TRUE, ci = c(50, 95))

# Occupancy species-level effects 
MCMCplot(out.sp$beta.samples[,51:75], ref_ovl = TRUE, ci = c(50, 95))

# Occupancy species-level effects 
MCMCplot(out.sp$beta.samples[,76:100], ref_ovl = TRUE, ci = c(50, 95))
(a) elevation
(b) distance border
(c) FLII
Figure 2: Species effects

Species effects using bayesplot

Code
library(bayesplot)
#mcmc_areas(outMCMC, regex_pars = "Nspecies_in_AP")
# mcmc_areas(outMCMC, regex_pars = "Nspecies_in_AP")

mcmc_intervals(out.sp$beta.samples[,26:50] , point_est = "mean",
               prob = 0.75, prob_outer = 0.95) + 
  geom_vline(xintercept = 0, color = "red", linetype = "dashed", size = 0.5)
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.

Code
mcmc_intervals(out.sp$beta.samples[,51:75] , point_est = "mean",
               prob = 0.75, prob_outer = 0.95) + 
  geom_vline(xintercept = 0, color = "red", linetype = "dashed", size = 0.5)

Code
mcmc_intervals(out.sp$beta.samples[,76:100] , point_est = "mean",
               prob = 0.75, prob_outer = 0.95) + 
  geom_vline(xintercept = 0, color = "red", linetype = "dashed", size = 0.5)

Prediction as graph

This prediction uses the non spatial model

Code
# 6. Prediction -----------------------------------------------------------
# Predict occupancy along a gradient of elev   
# Create a set of values across the range of observed elev values
elev.pred.vals <- seq(min(data_list$occ.covs$elev), 
                              max(data_list$occ.covs$elev), 
                              length.out = 100)
# Scale predicted values by mean and standard deviation used to fit the model
elev.pred.vals.scale <- (elev.pred.vals - mean(data_list$occ.covs$elev)) / 
                             sd(data_list$occ.covs$elev)
# Create a set of values across the range of observed elev values
border_dist.pred.vals <- seq(min(data_list$occ.covs$border_dist), 
                              max(data_list$occ.covs$border_dist), 
                              length.out = 100)
# Scale predicted values by mean and standard deviation used to fit the model
border_dist.pred.vals.scale <- (border_dist.pred.vals -
                                  mean(data_list$occ.covs$border_dist)) /
                                  sd(data_list$occ.covs$border_dist)

# Create a set of values across the range of observed FLII values
FLII.pred.vals <- seq(min(data_list$occ.covs$FLII), 
                              max(data_list$occ.covs$FLII), 
                              length.out = 100)
# Scale predicted values by mean and standard deviation used to fit the model
FLII.pred.vals.scale <- (FLII.pred.vals -
                                  mean(data_list$occ.covs$FLII)) /
                                  sd(data_list$occ.covs$FLII)

# Predict occupancy across elev  values at mean values of all other variables
pred.df1 <- as.matrix(data.frame(intercept = 1, 
                                 elev = elev.pred.vals.scale, 
                                 border_dist = 0,
                                 FLII=0))#, catchment = 0, density = 0, 
                         # slope = 0))
# Predict occupancy across elev  values at mean values of all other variables
pred.df2 <- as.matrix(data.frame(intercept = 1, elev = 0, 
                         border_dist = border_dist.pred.vals.scale,
                         FLII= 0 ))#, catchment = 0, density = 0, 
                         # slope = 0))
# Predict occupancy across elev  values at mean values of all other variables
pred.df3 <- as.matrix(data.frame(intercept = 1, elev = 0, 
                         border_dist = 0,
                         FLII= FLII.pred.vals.scale ))#, catchment = 0, density = 0, 
                         # slope = 0))

out.pred1 <- predict(out.null, pred.df1) # using non spatial
str(out.pred1)
List of 3
 $ psi.0.samples: num [1:1500, 1:25, 1:100] 0.2 0.427 0.357 0.246 0.105 ...
 $ z.0.samples  : int [1:1500, 1:25, 1:100] 0 1 0 0 0 0 0 0 0 0 ...
 $ call         : language predict.msPGOcc(object = out.null, X.0 = pred.df1)
 - attr(*, "class")= chr "predict.msPGOcc"
Code
psi.0.quants <- apply(out.pred1$psi.0.samples, c(2, 3), quantile, 
                          prob = c(0.025, 0.5, 0.975))
sp.codes <- attr(data_list$y, "dimnames")[[1]]
psi.plot.dat <- data.frame(psi.med = c(t(psi.0.quants[2, , ])), 
                                 psi.low = c(t(psi.0.quants[1, , ])), 
                                 psi.high = c(t(psi.0.quants[3, , ])), 
                           elev = elev.pred.vals, 
                                 sp.codes = rep(sp.codes, 
                                                each = length(elev.pred.vals)))

ggplot(psi.plot.dat, aes(x = elev, y = psi.med)) + 
  geom_ribbon(aes(ymin = psi.low, ymax = psi.high), fill = 'grey70') +
  geom_line() + 
  facet_wrap(vars(sp.codes)) + 
  theme_bw() + 
  labs(x = 'elevation (m)', y = 'Occupancy Probability') 

Code
out.pred2 <- predict(out.null, pred.df2) # using non spatial
str(out.pred2)
List of 3
 $ psi.0.samples: num [1:1500, 1:25, 1:100] 0.3322 0.4227 0.4671 0.3285 0.0758 ...
 $ z.0.samples  : int [1:1500, 1:25, 1:100] 0 0 1 0 0 0 0 0 0 0 ...
 $ call         : language predict.msPGOcc(object = out.null, X.0 = pred.df2)
 - attr(*, "class")= chr "predict.msPGOcc"
Code
psi.0.quants <- apply(out.pred2$psi.0.samples, c(2, 3), quantile, 
                          prob = c(0.025, 0.5, 0.975))
sp.codes <- attr(data_list$y, "dimnames")[[1]]
psi.plot.dat <- data.frame(psi.med = c(t(psi.0.quants[2, , ])), 
                                 psi.low = c(t(psi.0.quants[1, , ])), 
                                 psi.high = c(t(psi.0.quants[3, , ])), 
                           border_dist = border_dist.pred.vals, 
                                 sp.codes = rep(sp.codes, 
                                                each = length(border_dist.pred.vals)))

ggplot(psi.plot.dat, aes(x = border_dist/1000, y = psi.med)) + 
  geom_ribbon(aes(ymin = psi.low, ymax = psi.high), fill = 'grey70') +
  geom_line() + 
  facet_wrap(vars(sp.codes)) + 
  theme_bw() + 
  labs(x = 'border_dist (Km)', y = 'Occupancy Probability') 

Code
out.pred3 <- predict(out.null, pred.df3) # using non spatial
str(out.pred3)
List of 3
 $ psi.0.samples: num [1:1500, 1:25, 1:100] 0.388 0.986 0.849 0.881 0.362 ...
 $ z.0.samples  : int [1:1500, 1:25, 1:100] 0 1 1 1 0 1 1 0 1 0 ...
 $ call         : language predict.msPGOcc(object = out.null, X.0 = pred.df3)
 - attr(*, "class")= chr "predict.msPGOcc"
Code
psi.0.quants <- apply(out.pred3$psi.0.samples, c(2, 3), quantile, 
                          prob = c(0.025, 0.5, 0.975))
sp.codes <- attr(data_list$y, "dimnames")[[1]]
psi.plot.dat <- data.frame(psi.med = c(t(psi.0.quants[2, , ])), 
                                 psi.low = c(t(psi.0.quants[1, , ])), 
                                 psi.high = c(t(psi.0.quants[3, , ])), 
                           FLII = FLII.pred.vals, 
                                 sp.codes = rep(sp.codes, 
                                                each = length(FLII.pred.vals)))

ggplot(psi.plot.dat, aes(x = FLII/1000, y = psi.med)) + 
  geom_ribbon(aes(ymin = psi.low, ymax = psi.high), fill = 'grey70') +
  geom_line() + 
  facet_wrap(vars(sp.codes)) + 
  theme_bw() + 
  labs(x = 'FLII', y = 'Occupancy Probability') 

Spatial Prediction in elevation_EC

Code
#aggregate  resolution to (factor = 3)
#transform coord data to UTM
elevation_UTM <- project(elevation_EC, "EPSG:10603")
elevation_17.aggregate <- aggregate(elevation_UTM, fact=10)
res(elevation_17.aggregate)

# Convert the SpatRaster to a data frame with coordinates
df_coords <- as.data.frame(elevation_17.aggregate, xy = TRUE)
names(df_coords) <-c("X","Y","elev")

elev.pred <- (df_coords$elev - mean(data_list$occ.covs$elev)) / sd(data_list$occ.covs$elev)


############### Predict new data ############### 
# we predict at one covariate varing and others at mean value = 0
# intercept = 1, elev = 0, border_dist = 0, FLII= 0
# in that order
################ ################ ################ 
predict_data <- cbind(1, elev.pred, 0, 0)
colnames(predict_data) <- c("intercept",
                            "elev",
                            "border_dist",
                            "FLII" )

# X.0 <- cbind(1, 1, elev.pred)#, elev.pred^2)

# coords.0 <- as.matrix(hbefElev[, c('Easting', 'Northing')])
out.sp.ms.pred <- predict(out.sp, 
                          X.0=predict_data, 
                          df_coords[,1:2],
                          threads=4) #Warning :'threads' is not an argument

# extract the array of interest= occupancy
predicted_array <- out.sp.ms.pred$psi.0.samples



dim(predicted_array)
# df_plot <- NA # empty column
predicted_raster_list <- list() # rast(nrows = 52, ncols = 103,
                         #ext(elevation_17.aggregate), 
                         # crs = "EPSG:32717")

###################################################
# simpler way to make mean in the array by species
# array order: itera=3000, sp=22, pixels=5202
# we wan to keep index 2 and 3
library(plyr)
aresult = (plyr::aaply(predicted_array, # mean fo all iterations
                       c(2,3), 
                       mean))

##############################################
#### Loop to make rasters and put in a list
# array order: itera=3000, sp=22, pixels=5202
for (i in 1:dim(predicted_array)[2]){
 # Convert array slice to data frame
 # df_plot[i] <- as.data.frame(predicted_array[1, i, ]) # sp_i
 # df_plot[i] <- as.vector(aresult[i,]) # Extract sp
 # Producing an SDM for all (posterior mean)
 plot.dat <- data.frame(x = df_coords$X, 
                        y = df_coords$Y, 
                        psi.sp = as.vector(aresult[i,]))
 pred_rast <- rast(plot.dat, 
                   type = "xyz", 
                   crs = "EPSG:10603") # Replace EPSG:4326 with your CRS
 predicted_raster_list[[i]] <- pred_rast
}

# Convert the list to a SpatRaster stack
predictad_raster_stack <- rast(predicted_raster_list)
# put species names
names(predictad_raster_stack) <- selected.sp

plot(predictad_raster_stack)

# get the mean
predicted_mean <- mean(predictad_raster_stack)

plot(predicted_mean, main="mean occupancy")

mapview(predicted_mean) + mapview(AP_Yasuni_UTM_line)
# 

Package Citation

Code
pkgs <- cite_packages(output = "paragraph", pkgs="Session", out.dir = ".")
# knitr::kable(pkgs)
pkgs

We used R v. 4.4.2 (R Core Team 2024) and the following R packages: abind v. 1.4.8 (Plate and Heiberger 2024), bayesplot v. 1.14.0 (Gabry et al. 2019; Gabry and Mahr 2025), beepr v. 2.0 (Bååth 2024), camtrapR v. 3.0.0 (Niedballa et al. 2016), coda v. 0.19.4.1 (Plummer et al. 2006), DT v. 0.34.0 (Xie et al. 2025), elevatr v. 0.99.0 (Hollister et al. 2023), maps v. 3.4.3 (Becker et al. 2025), mapview v. 2.11.4 (Appelhans et al. 2025), MCMCvis v. 0.16.3 (Youngflesh 2018), sf v. 1.0.21 (Pebesma 2018; Pebesma and Bivand 2023), snow v. 0.4.4 (Tierney et al. 2021), snowfall v. 1.84.6.3 (Knaus 2023), spOccupancy v. 0.8.0 (Doser et al. 2022, 2024; Doser, Finley, and Banerjee 2023), terra v. 1.8.70 (Hijmans 2025), tictoc v. 1.2.1 (Izrailev 2024), tidyverse v. 2.0.0 (Wickham et al. 2019), tmap v. 4.2 (Tennekes 2018).

Sesion info

Code
print(sessionInfo(), locale = FALSE)
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: internal


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] abind_1.4-8       lubridate_1.9.4   forcats_1.0.0     stringr_1.5.2    
 [5] dplyr_1.1.4       purrr_1.1.0       readr_2.1.5       tidyr_1.3.1      
 [9] tibble_3.2.1      ggplot2_4.0.0     tidyverse_2.0.0   spOccupancy_0.8.0
[13] camtrapR_3.0.0    snowfall_1.84-6.3 snow_0.4-4        beepr_2.0        
[17] coda_0.19-4.1     MCMCvis_0.16.3    tictoc_1.2.1      bayesplot_1.14.0 
[21] elevatr_0.99.0    terra_1.8-70      tmap_4.2          maps_3.4.3       
[25] mapview_2.11.4    sf_1.0-21         DT_0.34.0         readxl_1.4.3     
[29] grateful_0.3.0   

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3      tensorA_0.36.2.1        rstudioapi_0.17.1      
  [4] audio_0.1-11            jsonlite_2.0.0          wk_0.9.4               
  [7] magrittr_2.0.3          farver_2.1.2            nloptr_2.1.1           
 [10] rmarkdown_2.30          vctrs_0.6.5             minqa_1.2.8            
 [13] base64enc_0.1-3         RcppNumerical_0.6-0     progress_1.2.3         
 [16] htmltools_0.5.8.1       leafsync_0.1.0          distributional_0.5.0   
 [19] curl_7.0.0              raster_3.6-32           cellranger_1.1.0       
 [22] s2_1.1.9                sass_0.4.10             bslib_0.9.0            
 [25] slippymath_0.3.1        KernSmooth_2.23-24      htmlwidgets_1.6.4      
 [28] plyr_1.8.9              cachem_1.1.0            stars_0.6-8            
 [31] uuid_1.2-1              mime_0.13               lifecycle_1.0.4        
 [34] iterators_1.0.14        pkgconfig_2.0.3         cols4all_0.8-1         
 [37] Matrix_1.7-1            R6_2.6.1                fastmap_1.2.0          
 [40] shiny_1.9.1             digest_0.6.37           colorspace_2.1-1       
 [43] leafem_0.2.4            crosstalk_1.2.1         labeling_0.4.3         
 [46] lwgeom_0.2-14           progressr_0.15.0        spacesXYZ_1.6-0        
 [49] timechange_0.3.0        httr_1.4.7              mgcv_1.9-1             
 [52] compiler_4.4.2          microbenchmark_1.5.0    proxy_0.4-27           
 [55] withr_3.0.2             doParallel_1.0.17       backports_1.5.0        
 [58] brew_1.0-10             S7_0.2.0                DBI_1.2.3              
 [61] logger_0.4.0            MASS_7.3-61             maptiles_0.10.0        
 [64] tmaptools_3.3           leaflet_2.2.3           classInt_0.4-11        
 [67] tools_4.4.2             units_0.8-7             leaflegend_1.2.1       
 [70] httpuv_1.6.16           glue_1.8.0              satellite_1.0.5        
 [73] nlme_3.1-166            promises_1.3.3          grid_4.4.2             
 [76] checkmate_2.3.2         reshape2_1.4.4          generics_0.1.3         
 [79] leaflet.providers_2.0.0 gtable_0.3.6            tzdb_0.4.0             
 [82] shinyBS_0.61.1          class_7.3-22            data.table_1.17.8      
 [85] hms_1.1.3               sp_2.2-0                RANN_2.6.2             
 [88] foreach_1.5.2           pillar_1.11.1           posterior_1.6.1        
 [91] later_1.4.2             splines_4.4.2           lattice_0.22-6         
 [94] tidyselect_1.2.1        knitr_1.50              svglite_2.1.3          
 [97] stats4_4.4.2            xfun_0.52               shinydashboard_0.7.3   
[100] leafpop_0.1.0           stringi_1.8.4           rematch_2.0.0          
[103] yaml_2.3.10             boot_1.3-31             evaluate_1.0.4         
[106] codetools_0.2-20        cli_3.6.5               RcppParallel_5.1.9     
[109] systemfonts_1.1.0       xtable_1.8-4            jquerylib_0.1.4        
[112] secr_5.1.0              dichromat_2.0-0.1       Rcpp_1.1.0             
[115] spAbundance_0.2.1       png_0.1-8               XML_3.99-0.18          
[118] parallel_4.4.2          prettyunits_1.2.0       lme4_1.1-35.5          
[121] mvtnorm_1.3-2           scales_1.4.0            e1071_1.7-16           
[124] crayon_1.5.3            rlang_1.1.6            

References

Appelhans, Tim, Florian Detsch, Christoph Reudenbach, and Stefan Woellauer. 2025. mapview: Interactive Viewing of Spatial Data in r. https://CRAN.R-project.org/package=mapview.
Bååth, Rasmus. 2024. beepr: Easily Play Notification Sounds on Any Platform. https://CRAN.R-project.org/package=beepr.
Becker, Richard A., Allan R. Wilks, Ray Brownrigg, Thomas P. Minka, and Alex Deckmyn. 2025. maps: Draw Geographical Maps. https://CRAN.R-project.org/package=maps.
Doser, Jeffrey W., Andrew O. Finley, and Sudipto Banerjee. 2023. “Joint Species Distribution Models with Imperfect Detection for High-Dimensional Spatial Data.” Ecology, e4137. https://doi.org/10.1002/ecy.4137.
Doser, Jeffrey W., Andrew O. Finley, Marc Kéry, and Elise F. Zipkin. 2022. spOccupancy: An r Package for Single-Species, Multi-Species, and Integrated Spatial Occupancy Models.” Methods in Ecology and Evolution 13: 1670–78. https://doi.org/10.1111/2041-210X.13897.
Doser, Jeffrey W., Andrew O. Finley, Sarah P. Saunders, Marc Kéry, Aaron S. Weed, and Elise F. Zipkin. 2024. “Modeling Complex Species-Environment Relationships Through Spatially-Varying Coefficient Occupancy Models.” Journal of Agricultural, Biological, and Environmental Statistics. https://doi.org/10.1007/s13253-023-00595-6.
Gabry, Jonah, and Tristan Mahr. 2025. bayesplot: Plotting for Bayesian Models.” https://mc-stan.org/bayesplot/.
Gabry, Jonah, Daniel Simpson, Aki Vehtari, Michael Betancourt, and Andrew Gelman. 2019. “Visualization in Bayesian Workflow.” J. R. Stat. Soc. A 182: 389–402. https://doi.org/10.1111/rssa.12378.
Hijmans, Robert J. 2025. terra: Spatial Data Analysis. https://CRAN.R-project.org/package=terra.
Hollister, Jeffrey, Tarak Shah, Jakub Nowosad, Alec L. Robitaille, Marcus W. Beck, and Mike Johnson. 2023. elevatr: Access Elevation Data from Various APIs. https://doi.org/10.5281/zenodo.8335450.
Izrailev, Sergei. 2024. tictoc: Functions for Timing r Scripts, as Well as Implementations of Stack and StackList Structures. https://CRAN.R-project.org/package=tictoc.
Knaus, Jochen. 2023. snowfall: Easier Cluster Computing (Based on snow). https://CRAN.R-project.org/package=snowfall.
Niedballa, Jürgen, Rahel Sollmann, Alexandre Courtiol, and Andreas Wilting. 2016. camtrapR: An r Package for Efficient Camera Trap Data Management.” Methods in Ecology and Evolution 7 (12): 1457–62. https://doi.org/10.1111/2041-210X.12600.
Pebesma, Edzer. 2018. Simple Features for R: Standardized Support for Spatial Vector Data.” The R Journal 10 (1): 439–46. https://doi.org/10.32614/RJ-2018-009.
Pebesma, Edzer, and Roger Bivand. 2023. Spatial Data Science: With applications in R. Chapman and Hall/CRC. https://doi.org/10.1201/9780429459016.
Plate, Tony, and Richard Heiberger. 2024. abind: Combine Multidimensional Arrays. https://CRAN.R-project.org/package=abind.
Plummer, Martyn, Nicky Best, Kate Cowles, and Karen Vines. 2006. CODA: Convergence Diagnosis and Output Analysis for MCMC.” R News 6 (1): 7–11. https://journal.r-project.org/archive/.
R Core Team. 2024. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Tennekes, Martijn. 2018. tmap: Thematic Maps in R.” Journal of Statistical Software 84 (6): 1–39. https://doi.org/10.18637/jss.v084.i06.
Tierney, Luke, A. J. Rossini, Na Li, and H. Sevcikova. 2021. snow: Simple Network of Workstations. https://CRAN.R-project.org/package=snow.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Xie, Yihui, Joe Cheng, Xianying Tan, and Garrick Aden-Buie. 2025. DT: A Wrapper of the JavaScript Library DataTables. https://CRAN.R-project.org/package=DT.
Youngflesh, Casey. 2018. MCMCvis: Tools to Visualize, Manipulate, and Summarize MCMC Output.” Journal of Open Source Software 3 (24): 640. https://doi.org/10.21105/joss.00640.

Reuse

Citation

BibTeX citation:
@online{forero2025,
  author = {Forero, German and Wallace, Robert and Zapara-Rios, Galo and
    Isasi-Catalá, Emiliana and J. Lizcano, Diego},
  title = {Yasuni {Spatial} {Factor} {Multi-Species} {Occupancy}
    {Model}},
  date = {2025-08-16},
  url = {https://dlizcano.github.io/Occu_APs_all/blog/2025-11-02-Yasuni/},
  langid = {en}
}
For attribution, please cite this work as:
Forero, German, Robert Wallace, Galo Zapara-Rios, Emiliana Isasi-Catalá, and Diego J. Lizcano. 2025. “Yasuni Spatial Factor Multi-Species Occupancy Model.” August 16, 2025. https://dlizcano.github.io/Occu_APs_all/blog/2025-11-02-Yasuni/.