1. Smithsonian National Zoo and Conservation Biology Institute, Conservation Ecology Center, 1500 Remount Rd, Front Royal, VA 22630, USA
  2. Institute of Crop Science, University of Hoffenheim, Stuttgart, Germany
  3. Lolldaiga Hills Research Programme, P.O. Box 26, Nanyuki, Kenya
  4. Sustainability Research Institute, School of Earth and Environment, University of Leeds, Woodhouse Lane, Leeds, LS9 9JT, UK
  5. Directorate of Resource Surveys and Remote Sensing, P.O. Box 47146-00100, Nairobi, Kenya
  6. Conservation and Ecology Group, University of Groningen, PO Box 11103, 9700 CC, Groningen, the Netherlands.
  7. Mpala Research Centre, P.O. Box 555, Nanyuki, Kenya
  8. Ecology and Evolutionary Biology, Princeton University, 106A Guyot Ln, Princeton, NJ 08544, USA

Access original publication at:

https://www.sciencedirect.com/science/article/abs/pii/S0006320719314466 link

Abstract

Private lands are critical for maintaining biodiversity beyond protected areas. Across Kenyan rangelands, wild herbivores frequently coexist with people and their livestock. Human population and livestock numbers are projected to increase dramatically over the coming decades. Therefore, a better understanding of wildlife-livestock interactions and their consequences for biodiversity conservation on private lands is needed. We used a Bayesian hierarchical, multi-species and multi-year occupancy model on aerial survey data of 15 wild-herbivore species, spanning 15 years (2001-2016) to investigate a) spatiotemporal trends in species occurrence and richness across a mosaic of properties with different land uses in Laikipia County, central Kenya; and b) the effects of distance to water, vegetation and livestock relative abundance on species occurrence and richness. Although mean herbivore species richness varied little over time, we observed high spatial variation in species occurrence across Laikipia, mainly driven by negative effects of high livestock relative abundance. As expected, ‘wildlife friendly’ properties had higher herbivore species richness than other areas. However, high variability suggests that some pastoral properties support rich herbivore communities. The area occupied by five species with global conservation concerns (reticulated giraffe, Grevy’s zebra, Beisa Oryx, Defassa waterbuck and gerenuk) and for which Laikipia County is one of the last refuges was <50% across years. We conclude that ‘wildlife friendly’ properties remain crucial for conservation, although some pastoralist areas offer suitable habitats for wild herbivores. Effective management of stocking rates is critical for maintaining ecosystems able to sustain livestock and wildlife on private lands, ensuring protection for endangered species.

Introduction

Protected areas are essential for the conservation of global biodiversity (Watson et al., 2014). Yet, the effectiveness of the global system of protected areas is recognized as largely insufficient (Ceballos et al., 2005). Few reserves are large enough to satisfy the home range requirements of many species (Caro and Paul, 2007), while fewer still incorporate the broad-scale variation in resources necessary to maintain large-scale seasonal migrations (Fynn and Bonyongo, 2010; Tack et al., 2019) and/or ensure protection of large populations that are critical for long-term persistence (Newmark, 2008; Western et al., 2009b). Consequently, significant populations of large mammals occur on lands that lack formal protection (Ceballos et al., 2005; Ogutu et al., 2016, Western et al., 2009b). Enhancing conservation actions in private lands where wildlife coexist with human activities will become increasingly important if wildlife are to persist into the future (Drescher and Brenner, 2018; Nelson, 2008).

Across grassland ecosystems globally, large herbivores play critical roles in maintaining biodiversity (Mortensen et al., 2018; Post, 2013). The spatiotemporal heterogeneity in structure, productivity, phenology and composition of plant communities dictates the diversity and population stability of large herbivores (Fynn et al., 2016; Owen-Smith, 2004). Grazing by large herbivores, at the same time, improves pasture quality and maintains heterogeneity, enabling grass-dominated ecosystems to support more herbivore biomass than other terrestrial habitats (Frank et al., 1998; Knapp et al., 1999; Huntly, 1991). Across Africa, savannahs support more diversity and abundance of large herbivore species than any other continent, with wildlife coexisting alongside pastoralists and their livestock (du Toit and Cumming, 1999; Reid et al., 2008). Ecosystem benefits has been shown to increase when livestock are kept at moderate densities (Keesing et al., 2018). The presence of livestock, for instance, can reduce ectoparasites abundance when using acaricides (Tallis et al., 2017), improve pasture quality (Young et al., 2018) and promote vegetation heterogeneity through concentration of nutrients (glades; Augustine et al., 2003). At higher stocking rates, however, livestock can negatively affect wildlife due to competition for forage, water and space (du Toit and Cumming, 1999; Georgiadis et al., 2007; Prins, 2000; Western et al., 2009a).

Laikipia County in central Kenya represents an example of successful conservation across private lands where wildlife, people and livestock coexist. This rangeland supports an abundant wildlife community, second only to the Greater Mara ecosystem in Kenya (Ogutu et al., 2016). In Laikipia, local people find economic benefits from the integration of wildlife tourism with livestock commercialization (Keesing et al., 2018). However, coexisting with wildlife can also pose serious challenges, such as economic losses due to increased human-wildlife conflict, the transfer of zoonotic diseases and competition for resources (du Toit et al. 2017). The rapid human population growth across the region, together with a complex process of sedentarization, erosion of traditional governance strategies and an increase in livestock densities and associated overgrazing (Letai and Lind, 2013), is exacerbating pressures on wildlife and the ecological stability of the ecosystem.

Across Laikipia’s rangelands, there has been a general decline in the density of large-wild herbivores within properties that do not actively protect wildlife, as well as evidence of spatial segregation of wildlife and livestock over a 21-year period (1985-2005; Georgiadis et al., 2007). However, the species studied accounted for <15% of regional large mammal richness (Kinnaird and O’Brien, 2012). Kinnaird and O’Brien (2012) assessed a larger number of species using camera trap data on eight properties across Laikipia (10% of the county) during 2008-2010 and found segregation in species occupancy and richness by land use, noting that species were concentrated in ‘wildlife friendly’ properties. To our knowledge, spatially explicit temporal trends in herbivore species richness and species-specific occupancy and their drivers have not been investigated across this system. Yet, this information is critical to provide an improved understanding of the interplay between wildlife communities and the increasing livestock abundance that can guide future conservation actions in rangeland ecosystems.

In this study, we expand upon previous research by investigating a) trends in herbivore occupancy and richness across different land uses in Laikipia County over the past two decades and b) how environmental variables and livestock relative abundance affect herbivore occupancy and species richness dynamics. For this we used the aerial survey dataset collected by Kenya’s Directorate of Resource Surveys and Remote Sensing (DRSRS) and a Bayesian hierarchical multi-species and multi-year occupancy modeling approach (Dorazio et al., 2006; Goijman et al., 2015; Royle and Dorazio, 2008; Zipkin et al., 2009). It is well recognized that animals are imperfectly detected during aerial surveys (Jachmann, 2002; Schlossberg et al., 2018), leading to many species with too few sightings for individual analysis (Royle and Dorazio, 2008; Zipkin et al., 2009). Recent advances in statistical modeling of species occurrence address these problems by accounting for detection probability through repeated sampling and improving parameter estimates by sharing information across species – important for species with few detections (Dorazio et al., 2006; Royle and Dorazio, 2008; Zipkin et al., 2009).

Materials and Methods

Load libraries and set the working directory

Study area

Laikipia County (Fig. 1), Kenya, encompasses c. 9700 km2, covered by a mosaic of semi-arid savannah and woodlands. The vegetation composition varies according to the two main soil types; clay-rich ‘black cotton’ soils (vertisols) and well-drained sandy ‘red soils’ (luvisols). In ‘black cotton’ soils, woodlands are primarily composed of Acacia drepanolobium. Grass cover is dominated by Pennisetum mezianum, P. stramineum, Bracharia lachnantha, Themeda triandra and Lintonia nutans (Young et al., 1997). In ‘red soils’, the most important woody species include A. mellifera, A. etbaica and A. brevispica. The more sparse grass cover in these areas is characterized by an abundance of Digitaria milanjiana, Cynodon dactylon, P. stramineum and and Tetrapogon (formerly Chloris) roxburghiana (Butynski and de Jong, 2014). Dry forests exist across Laikipia but are restricted to elevated areas and dominated by Juniperus procera, Olea europaea, Afrocarpus gracilior, Euclea divinorum, Acokanthera schimperi and Croton megalocarpus (Butynski and de Jong, 2014).

Mt. Kenya (5199 m.a.s.l.) in the south-east and the Aberdare highlands (3990 m.a.s.l.) in the south-west determine the rainfall gradient, ranging from 1200 mm of rainfall close to the mountain ranges to 400 mm in the northern areas of the county (Butynski and de Jong, 2014). Rainfall is weakly trimodal, with the majority of precipitation falling in March-May (long rains) and October-December (short rains). Occasional continental rains occur in June-September, particularly in the west. The main dry season is January-February (Schmocker et al., 2015). From Mt. Kenya and the Aberdare highlands flow a series of permanent and seasonal rivers across the plateau. Rainfall patterns are changing, with impacts on both wildlife and livestock movement across this landscape (Schmocker et al., 2015).

A long period of colonial and post-colonial policies has resulted in a dynamic mosaic of land uses and land tenures across the region. These properties include communally owned pastoralist areas, privately owned agricultural plots, commercial cattle ranches and conservancies (Sundaresan and Riginos, 2010). For this study, we focused on the semi-arid rangelands, excluding most of the areas dedicated to small-scale agriculture where most wildlife has been extirpated (Georgiadis et al., 2007). We classified properties into four categories (‘wildlife only’, ‘ranching and wildlife’, ‘ranching’, and ‘pastoralist’) following the County Government of Laikipia (2018) standards (Fig. A1). ‘Wildlife only’ properties are areas dedicated exclusively to wildlife conservation. In these areas, livestock are generally absent. ‘Ranching and wildlife’ properties include conservancies and ranches that are managed to protect wildlife, to conduct science and for tourism, but that also manage livestock at moderated stocking levels. Collectively, these two land uses are referred to as ‘wildlife friendly’. ‘Ranching’ properties are exclusively dedicated to commercial ranching, and in general, do not tolerate wildlife. ‘Pastoralist’ areas are private, communal or government lands in which livestock production is the primary economic activity for people, resulting in areas managed with high levels of livestock (e.g., > 25 total livestock units per 1 km2). For further information on land uses see: Sundaresan and Riginos (2010) and Kinnaird and O’Brien (2012).Laikipia County, Kenya, encompasses c. 9700 km2 of plateau area, covered by a mosaic of semi-arid savannah and woodlands. The vegetation composition varies according to the main two soil types; clay-rich ‘black cotton’ soils (vertisols) and well-drained sandy ‘red soils’ (luvisols). In ‘black cotton’ soils, woodlands are primarily composed of Acacia drepanolobium. Grass cover is dominated by Pennisetum mezianum, P. stramineum, Bracharia lachnantha, Themeda triandra and Lintonia nutans (Young et al., 1997). In ‘red soils’, the most important woody species include A. mellifera, A. etbaica and A. brevispica. The more sparse grass cover in these areas is characterized by an abundance of Digitaria milanjiana, Cynodon dactylon, P. stramineum and Cloris roxburghiana (Butynski and de Jong, 2014). Dry forests exist across Laikipia but are restricted to elevated areas and dominated by Juniperus procera, Olea europaea, Afrocarpus gracilior, Euclea divinorum, Acokanthera schimperi and Croton megalocarpus (Butynski and de Jong, 2014).

Fig. 1. The study area in Laikipia County, Kenya. The county is divided into a mosaic of properties with different land uses including small agricultural plots (Mixed farming), pastoralism, commercial cattle ranches (Ranching) and pro-wildlife ranches and conservancies (Ranching and wildlife). A few properties are exclusively used for wildlife conservation (Wildlife only). The study is focused on the semi-arid rangelands excluding most of the mixed farming properties where most wildlife has been extirpated.
## Reading layer `Property_boundary_2015' from data source `C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles\Property_boundary_2015.shp' using driver `ESRI Shapefile'
## Simple feature collection with 315 features and 18 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 186885.9 ymin: -32707.34 xmax: 321651.3 ymax: 96041.66
## projected CRS:  WGS 84 / UTM zone 37N

Aerial survey dataset

To evaluate the spatiotemporal dynamics of herbivore richness and occupancy across the region, we used aerial survey data collected during 2001, 2004, 2006, 2008, 2010, 2012, 2015 and 2016 by DRSRS, in partnership with the Laikipia Wildlife Forum (LWF) and the Mpala Research Centre. Aerial surveys are generally conducted across Kenya during the end of the dry season (February-March), with the entire county of Laikipia surveyed in 5-14 days (2001: 10-23 February; 2004: 20 February-1 March; 2006: 15-22 February; 2008: 6-10 March; 2010: 16-26 February; 2012: 4-9 March; 2015: 17 Feb-12 March; 2016; 14-19 April). In addition to the pilot, the survey crew consists of one front-seat observer and two rear-seat observers.

Flights are conducted at a constant speed of approximately 200 km/h at 120 m above ground level. Rear-seat observers count all animals detected between a 141 m strip width demarcated by parallel rods on the wing struts on each side of the plane. For herds >10 animals, photographs are taken for later corroboration of group size. Parallel transects regularly spaced 2.5 km apart were flown north-to-south following the Universal Transverse Mercator (UTM) coordinate system. Transects were sub-divided at 5 km sub-unit intervals. For more details about the aerial survey, see Georgiadis et al., (2007) and Ogutu et al. (2016).

To obtain the replication needed to estimate detectability, we arranged the aerial survey data in 288, 5 × 5 km cells (primary sampling units), each composed of two transect segments (secondary sampling units) of 2.5 × 5 km (Fig. 2). Using spatial, as opposed to temporal, replicates poses the risk of violating the assumption of constant occupancy status across replicates during the sampling period, confounding non-detection with absence and inflating occupancy estimates (Guillera-Arroita, 2011; Kendal and White, 2009). In this study, we assumed that if the species was present at one spatial replicate, it was also present at the second one (i.e., constant occupancy in the cell), given that ungulates are highly mobile species during the dry season (Owen-Smith, 2014) and transects were visited sequentially (Kendal and White, 2009).

We considered 15 species of wild herbivores for which we had detection data, including nine grazers (African buffalo (Syncerus caffer), Grevy’s zebra (Equus grevyi), plains zebra (Equus quagga), hartebeest (Alcelaphus buselaphus lelwel), Defassa waterbuck (Kobus ellipsiprymnus defassa), Grant’s gazelle (Nanger granti), Thomson’s gazelle (Eudorcas thomsonii), common warthog (Phacochoerus africanus), and ostrich (Struthio camelus)), two browsers (reticulated giraffe (Giraffa reticulata) and gerenuk (Litocranius walleri)) and four mixed-feeders (savanna elephant (Loxodonta africana), eland (Taurotragus oryx), impala (Aepyceros melampus), and Beisa oryx (Oryx beisa)).

Fig. 2. Primary (cells) and secondary (segments) sampling units used to assess spatiotemporal dynamics of 15 species of the herbivore community of Laikipia, Kenya, using a Bayesian hierarchical multi-species and multi-year occupancy models.

Data pre-preparation

#Loading and orginizig aerial survey data per year
Lai2001 <- read.csv("./Data/Laikipia2001.csv", header = T)
Lai2004 <- read.csv("./Data/Laikipia2004.csv", header = T)
Lai2006 <- read.csv("./Data/Laikipia2006.csv", header = T)
Lai2008 <- read.csv("./Data/Laikipia2008.csv", header = T)
Lai2010 <- read.csv("./Data/Laikipia2010.csv", header = T)
Lai2012 <- read.csv("./Data/Laikipia2012.csv", header = T)
Lai2015 <- read.csv("./Data/Laikipia2015.csv", header = T)
Lai2016 <- read.csv("./Data/Laikipia2016.csv", header = T)

#Besides years 2001 and 2010, we need to sum the observations of both right and left observers per transect.
Lai2001[is.na(Lai2001)] <- 0 #Replace NAs for 0
Lai2004[is.na(Lai2004)] <- 0 #Replace NAs for 0
Lai2004<-as.data.frame(Lai2004 %>% group_by(UNIT) %>% summarise_each(funs(sum))) #Remove columns and add counts per observer
Lai2006[is.na(Lai2006)] <- 0 #Replace NAs for 0
Lai2006<-as.data.frame(Lai2006 %>% group_by(UNIT) %>% summarise_each(funs(sum))) 
Lai2008[is.na(Lai2008)] <- 0 #Replace NAs for 0
Lai2008<-as.data.frame(Lai2008 %>% group_by(UNIT) %>% summarise_each(funs(sum)))
Lai2010[is.na(Lai2010)] <- 0 #Replace NAs for 0
Lai2012[is.na(Lai2012)] <- 0 #Replace NAs for 0
Lai2012<-as.data.frame(Lai2012 %>% group_by(UNIT) %>% summarise_each(funs(sum))) 
Lai2015[is.na(Lai2015)] <- 0 #Replace NAs for 0
Lai2015<-as.data.frame(Lai2015 %>% group_by(UNIT) %>% summarise_each(funs(sum))) 
Lai2016[is.na(Lai2016)] <- 0 #Replace NAs for 0
Lai2016<-as.data.frame(Lai2016%>% group_by(UNIT) %>% summarise_each(funs(sum))) 

Load aerial survey units shapefile to match the aerial survey data.

## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles", layer: "SurveyUNITS"
## with 707 features
## It has 4 fields

Merge the survey information with the sample units. The sample unit is the unique number of each 5 km transect. This will result in polygons with the abundance data as attributes.

Load the centroid points of each smapling unit (2.5 x 5 km) to extract the abundnce data.

From all the 2.5 x 5 km units from Laikipia, we selected those with low anthropogenic land cover.

Create a column with Cell ID (primary sampling units) and another column with Segment ID (secondary sampling units).

## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles", layer: "OccPoints2"
## with 576 features
## It has 8 fields

Extract survey data for all species. Here we use the point.in.poly function to extract data on animal abundance from the sampling units. After, we save the attribute table of each year as new data frames.

Create a loop to orginize the data in species, year, cell and segment.

#Create a vector with the name of the 15 species to work with
SpList<-c("EL","GF","ZB","ZG","TG","GG","KG","IM","BF","ED","OS","WH","OX","WB","GN")

##2001
det01<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data01[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data01$Cell, Rep=data01$Seg, Year=2001)
  det01<-rbind(det01,sp2)
}

##2004
det04<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data04[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data04$Cell, Rep=data04$Seg, Year=2004)
  det04<-rbind(det04,sp2)
}

##2006
det06<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data06[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data06$Cell, Rep=data06$Seg, Year=2006)
  det06<-rbind(det06,sp2)
}

##2008
det08<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data08[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data08$Cell, Rep=data08$Seg, Year=2008)
  det08<-rbind(det08,sp2)
}

##2010
det10<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data10[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data10$Cell, Rep=data10$Seg, Year=2010)
  det10<-rbind(det10,sp2)
}

##2012
det12<-data.frame()
for (i in 1:length(SpList)){
    sp1<-data12[,SpList[i]]
    sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data12$Cell, Rep=data12$Seg, Year=2012)
    det12<-rbind(det12,sp2)
}

##2015
det15<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data15[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data15$Cell, Rep=data15$Seg, Year=2015)
  det15<-rbind(det15,sp2)
}

##2016
det16<-data.frame()
for (i in 1:length(SpList)){
  sp1<-data16[,SpList[i]]
  sp2<-data.frame(Species=SpList[i], Det=sp1, Cell=data16$Cell, Rep=data16$Seg, Year=2016)
  det16<-rbind(det16,sp2)
}

#Combine datasets into one data frame.
det<-rbind(det01,det04,det06,det08,det10,det12,det15,det16)

#Extract the number of observed species.
n<-length(SpList)
n
## [1] 15
## [1] 288
## [1] 2
## [1] 8

Create a loop to transpose the segments into a data frame per year with the capture history for each cell. Check the structure and head of the new data frame.

## 'data.frame':    34560 obs. of  4 variables:
##  $ Species: Factor w/ 15 levels "EL","GF","ZB",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Year   : num  2001 2001 2001 2001 2001 ...
##  $ X1     : num  NA NA 0 0 0 0 0 0 0 0 ...
##  $ X2     : num  0 0 0 0 0 0 0 0 0 0 ...

Reshape the detection/non-detection data into a four-dimensional array DetHist, where the first dimension, J, is the cell; the second dimension, I, is the seg; the third dimension, n, is the species, and the fouth dimension, Y, is the year.

Convert abundance data into presence/absence data.

##       [,1] [,2]
##  [1,]   NA    0
##  [2,]   NA    0
##  [3,]    0    0
##  [4,]    0    0
##  [5,]    0    0
##  [6,]    0    0
##  [7,]    0    0
##  [8,]    0    0
##  [9,]    0    0
## [10,]    0    0

This is the array to use for modeling.

Covariates for detectability

We hypothesized that detectability may be affected by group size and woody vegetation cover (Jachmann, 2002; Schlossberg et al., 2018). We obtained records of group size from the aerial surveys for years 2006, 2008 and 2010. We calculated the mean group size for each species to account for its potential effect on species detectability (Table 1).

Calculate group size

#2006 - Original data only had the final count.
GrpSize2006 <- read.csv("./Data/groupsize2006.csv", header = T)
GrpSize2006$UNIT<-as.factor(GrpSize2006$UNIT)
GrpSize2006$Sp<-as.factor(GrpSize2006$Sp)

#2008 - Original data has visual counts and counts on photographs (group size > 10 individuals). 
GrpSize2008 <- read.csv("./Data/groupsize2008.csv", header = T)
GrpSize2008$UNIT<-as.factor(GrpSize2008$UNIT)
GrpSize2008$VCnt[is.na(GrpSize2008$VCnt)] <- 0 #Fill NA with zeros as the original csv files has no data for zeros.
GrpSize2008$PCnt[is.na(GrpSize2008$PCnt)] <- 0 #Fill NA with zeros as the original csv files has no data for zeros.
GrpSize2008<-within(GrpSize2008, CCnt<-ifelse(PCnt>0, PCnt, VCnt)) #Create a new count column that utilze the value of counts done on photographs when available.

#2010 - Original data only had the final count.
GrpSize2010 <- read.csv("./Data/groupsize2010.csv", header = T)
GrpSize2010$UNIT<-as.factor(GrpSize2010$UNIT)

#Extract only desire UNITS

SamplingUNITS<-unique(data04$UNIT)[-1] #-1 to eliminate the first value that is NA
StAreaGrpSize06<-subset(GrpSize2006, UNIT=SamplingUNITS)
StAreaGrpSize08<-subset(GrpSize2008, UNIT=SamplingUNITS)
StAreaGrpSize10<-subset(GrpSize2010, UNIT=SamplingUNITS)
StAreaGrpSize<-rbind(StAreaGrpSize06,StAreaGrpSize08,StAreaGrpSize10)

#Create a new dataframe with group size per species
GroupSize<-data.frame()
for (i in 1:length(SpList)){
  x<-subset(StAreaGrpSize, Sp==SpList[i])
  spmean<-mean(x$CCnt)
  spmedian<-median(x$CCnt)
  spSD<-sd(x$CCnt)
  spMin<-min(x$CCnt)
  spMax<-max(x$CCnt)
  datfra<-data.frame(Species=SpList[i],MeanGrSize=spmean,MedianGS=spmedian,SDGS=spSD,MinGS=spMin,MaxGS=spMax,NumGrps=nrow(x))
  GroupSize<-rbind(GroupSize,datfra)
}
GroupSize[1:2,]
##   Species MeanGrSize MedianGS     SDGS MinGS MaxGS NumGrps
## 1      EL   6.056701        5 5.194844     1    29     194
## 2      GF   3.568627        2 3.098736     1    19     153
Table 1. Group size summaries for 15 species of wild herbivores observed during aerial surveys for years 2006, 2008 and 2010 in Laikipia, Kenya.
Species Scientific name Mean group size Median group size Group size SD Min. group size Max. group size
Elephant Loxodonta africana 6.06 5.00 5.19 1 29
Reticulated giraffe Giraffa reticulata 3.57 2.00 3.10 1 19
Plains zebra Equus quagga 11.18 8.00 11.44 1 116
Grevy’s zebra Equus grevyi 4.33 3.50 3.50 1 16
Thomson’s gazelle Eudorcas thomsonii 6.76 6.00 5.35 1 28
Grant’s gazelle Nanger (granti) notata 5.11 4.00 4.04 1 24
Hartebeest Alcelaphus buselaphus lelwel 6.53 5.00 6.82 1 34
Impala Aepyceros melampus 9.14 6.00 10.43 1 65
African buffalo Syncerus caffer 16.06 6.50 25.86 1 146
Eland Taurotragus oryx 6.13 4.00 8.76 1 76
Ostrich Struthio camelus 2.02 1.00 2.84 1 26
Common warthog Phacochoerus africanus 3.62 3.00 2.40 1 11
Beisa oryx Oryx beisa 7.14 2.00 10.12 1 43
Defassa waterbuck Kobus ellipsiprymnus defassa 3.96 3.00 2.37 1 11
Gerenuk Litocranius walleri 1.59 1.00 0.75 1 4

Additionally, we used data on above ground woody vegetation biomass (WVB) from 2010 to account for vegetation effects on animals’ detectability (Bouvet et al., 2018). To test the assumption that this dataset accurately represented woody vegetation cover in Laikipia, we randomly selected 100, 50 × 50 m cells across the study area. We then used Google Earth high-resolution imagery from 2009-2012 to visually estimate woody vegetation cover in each cell to the nearest 5%, achieving r = 0.82 (Fig. 3). As the exact path taken by the airplane during flights was not provided with the survey metadata, we estimated mean WVB from Bouvet et al., (2018) for the entire 2.5 × 5 km segment using zonal statistics in QGIS3.2 (QGIS Development Team, 2018). We assumed WVB to be consistent through time.

## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\BushCover", layer: "RandPointsForAGB"
## with 100 features
## It has 1 fields
## Integer64 fields read as strings:  id
## [1] 0.82
## 
## Call:
## lm(formula = ForCorr$Obs ~ ForCorr$Est)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -37.167  -5.215  -1.564   3.525  50.794 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  4.56435    1.80611   2.527   0.0131 *  
## ForCorr$Est  0.68804    0.04943  13.919   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 13.6 on 96 degrees of freedom
## Multiple R-squared:  0.6687, Adjusted R-squared:  0.6652 
## F-statistic: 193.7 on 1 and 96 DF,  p-value: < 2.2e-16
Figure. 3. Correlation between estimated bush/tree cover and woody vegetation biomass obtained from Bouvet et al. (2018).

We obtained a correlation of 0.82 (p < 0.01). We concluded that we can use AGB to estimate bush/tree cover in each segment sampled.

As the exact path taken by the airplane during flights is not provided with survey metadata, we estimated mean WVB from Bouvet et al., (2018) for the entire 2.5 x 5 km segment using zonal statistics in QGIS3.2 (QGIS Development Team, 2018). We assumed WVB to be consistent across time periods.

## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles", layer: "SegmForOccu"
## with 730 features
## It has 6 fields
##           X1      X2
## [1,] 12.7990  4.2489
## [2,]  4.2556  7.7199
## [3,] 67.5055 71.9713
## [4,] 53.8961 66.3287
## [5,] 40.0471 33.0021
## [6,] 26.0596 26.7305

Covariates for occupancy

We incorporated distance to water as a covariate to account for its known effects on herbivore distribution (Ogutu et al., 2014b, 2010; Redfern et al., 2003; Sitters et al., 2009; Tyrrell et al., 2017). For each cell, we estimated the Euclidean distance from the center of the cell to the closest water source, including permanent rivers (obtained from the World Resources Institute [datasets.wri.org] and corrected using Google Earth Imagery) and permanent artificial dams. To incorporate dams, we used a global surface water layer (Pekel et al., 2016), retaining pixels containing water for >10 months per year between 1984 and 2015. We accounted for forage availability effects on herbivore distribution by incorporating the Normalized Difference Vegetation Index (NDVI) from the 1 km MODIS/Terra data product (MYD13A2). The NDVI has been proven to be a good predictor for distribution and abundance of herbivore species (Pettorelli et al., 2011; Sitters et al., 2009; Tyrrell et al., 2017). For each surveyed year, we obtained all images between January 1 (i.e., beginning of the dry season) and the last day of the survey and calculated the median value for each pixel. For each year, we then calculated the median value of NDVI for each cell using zonal statistics.

## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles", layer: "CellsForOccu"
## with 365 features
## It has 22 fields
## Integer64 fields read as strings:  Area
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\CregoRD\Documents\GitHub\CommunityOccupancy\Shapefiles", layer: "MayorRivers&DamsUTM37N"
## with 210 features
## It has 5 fields

Google Earth Engine code to process and download Modis NDVI information

var aoi = ee.Geometry.Polygon(
  [[[36.1, 0.95],
  [36.1, -0.5],
  [37.7, -0.5],
  [37.7, 0.95]]])

Map.centerObject(aoi)
var modis = ee.ImageCollection("MODIS/006/MOD13A2");
var modis01 = ee.ImageCollection(modis)
              .filterDate('2001-01-01', '2001-2-23')
              .select('NDVI');
              
var modisclip01 = modis01.median().clip(aoi);
var modisclip01 = modisclip01.multiply(0.0001);

var modis04 = ee.ImageCollection(modis)
              .filterDate('2004-01-01', '2004-3-1')
              .select('NDVI');
              
var modisclip04 = modis04.median().clip(aoi);
var modisclip04 = modisclip04.multiply(0.0001);

var modis06 = ee.ImageCollection(modis)
              .filterDate('2006-01-01', '2006-2-22')
              .select('NDVI');
              
var modisclip06 = modis06.median().clip(aoi);
var modisclip06 = modisclip06.multiply(0.0001);

var modis08 = ee.ImageCollection(modis)
              .filterDate('2008-01-01', '2008-3-10')
              .select('NDVI');
              
var modisclip08 = modis08.median().clip(aoi);
var modisclip08 = modisclip08.multiply(0.0001);

var modis10 = ee.ImageCollection(modis)
              .filterDate('2010-01-01', '2010-2-26')
              .select('NDVI');
              
var modisclip10 = modis10.median().clip(aoi);
var modisclip10 = modisclip10.multiply(0.0001);

var modis12 = ee.ImageCollection(modis)
              .filterDate('2012-01-01', '2012-3-09')
              .select('NDVI');
              
var modisclip12 = modis12.median().clip(aoi);
var modisclip12 = modisclip12.multiply(0.0001);

var modis15 = ee.ImageCollection(modis)
              .filterDate('2015-01-01', '2015-3-12')
              .select('NDVI');
              
var modisclip15 = modis15.median().clip(aoi);
var modisclip15 = modisclip15.multiply(0.0001);

var modis16 = ee.ImageCollection(modis)
              .filterDate('2016-01-01', '2016-4-19')
              .select('NDVI');
              
var modisclip16 = modis16.median().clip(aoi);
var modisclip16 = modisclip16.multiply(0.0001);

Map.addLayer(modisclip16, {min: 0, max: 1, palette: ['FFFFFF','CC9966','CC9900',
'996600', '33CC00', '009900','006600','000000']}, 'NDVI');

Export.image.toDrive({
  image: modisclip01,
  description: "Laikipia01",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip04,
  description: "Laikipia04",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip06,
  description: "Laikipia06",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip08,
  description: "Laikipia08",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip10,
  description: "Laikipia10",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip12,
  description: "Laikipia12",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip15,
  description: "Laikipia15",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

Export.image.toDrive({
  image: modisclip16,
  description: "Laikipia16",
  scale: 1000,
  folder:"GIS",
  maxPixels: 50100100100 
});

We incorporated livestock abundance effects on wild herbivore occurrence (Georgiadis et al., 2007; Keesing et al., 2018; Ogutu et al., 2014a; Sitters et al., 2009) by calculating the total counts of cattle, sheep, goats, camels and donkeys for each cell from the aerial survey dataset as a measure of relative abundance. We did not account for detectability in livestock counts because livestock occur in large highly detectable herds. Additionally, herds >10 animals are confirmed by photographs. We used single-season occupancy models to confirm that livestock detectability was close to one and that it was not affected by WVB. We assumed that livestock counts are a good measure of livestock relative abundance across the study area and that there is no spatial variation given by errors in counting animals that could obscure effects when using livestock counts as a covariate for herbivore occurrence.

#Livestock abundance (cattle, shoats, cammels, donkeys)

SpListDom<-c("CX","SH","DN","CM")

##2001
detdom01<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data01[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data01$Cell, Rep=data01$Seg, Year=2001)
  detdom01<-rbind(detdom01,sp2)
}

##2004
detdom04<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data04[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data04$Cell, Rep=data04$Seg, Year=2004)
  detdom04<-rbind(detdom04,sp2)
}

##2006
detdom06<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data06[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data06$Cell, Rep=data06$Seg, Year=2006)
  detdom06<-rbind(detdom06,sp2)
}

##2008
detdom08<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data08[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data08$Cell, Rep=data08$Seg, Year=2008)
  detdom08<-rbind(detdom08,sp2)
}

##2010
detdom10<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data10[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data10$Cell, Rep=data10$Seg, Year=2010)
  detdom10<-rbind(detdom10,sp2)
}

##2012
detdom12<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data12[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data12$Cell, Rep=data12$Seg, Year=2012)
  detdom12<-rbind(detdom12,sp2)
}

##2015
detdom15<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data15[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data15$Cell, Rep=data15$Seg, Year=2015)
  detdom15<-rbind(detdom15,sp2)
}

##2016
detdom16<-data.frame()
for (i in 1:length(SpListDom)){
  sp1<-data16[,SpListDom[i]]
  sp2<-data.frame(Species=SpListDom[i], Det=sp1, Cell=data16$Cell, Rep=data16$Seg, Year=2016)
  detdom16<-rbind(detdom16,sp2)
}

detdom<-rbind(detdom01,detdom04,detdom06,detdom08,detdom10,detdom12,detdom15,detdom16)

## Transpose the segments into a dataframa with capture history for each cell
detectionsDom<-data.frame()
for (y in 1:Y){
  for (i in 1:length(SpListDom)){
    dat0<-subset(detdom, Year==Years[y])
    dat1<-subset(dat0, Species==SpListDom[i])
    for (j in 1:J){
      dat2<-subset(dat1, Cell==j)
      dat3<-as.data.frame(t(dat2[-1]))
      dat4<-data.frame(Species=SpListDom[i], Year=Years[y], X1=dat3[1,1],X2=dat3[1,2])
      detectionsDom<-rbind(detectionsDom, dat4)
    }
  }
}


#Estimate total abundance per cell and per year.
detectionsDom$sum<-apply(detectionsDom[,3:4], 1, sum, na.rm=T)

#Sum the abundance of four species per year
AbunDom <- matrix(NA, nrow = J, ncol = Y)
dat2<-matrix(NA, nrow = J, ncol = length(SpListDom))
for (y in 1:Y) {
  dat0<-subset(detectionsDom, Year==Years[y]) 
  for (i in 1:length(SpListDom)){
    dat1<-subset(dat0, Species==SpListDom[i])
    dat2[,i]<-dat1$sum
    dat3<-apply(dat2, 1, sum)
   }
  AbunDom[,y]<-dat3
}

AbunDom<-as.data.frame(AbunDom)
colnames(AbunDom)<-c("2001","2004","2006","2008","2010","2012","2015","2016")
AbunDom<-replace(AbunDom,is.na(AbunDom),0)
head(AbunDom)
##   2001 2004 2006 2008 2010 2012 2015 2016
## 1   94  396   38  512  252   44  307  266
## 2    0   22  223  148  151   41  274  338
## 3   96   24  149  190    0   26  263   27
## 4   44   85  370  161    0    0   77  198
## 5  340   27  151    0    0    0  216    0
## 6  129   62   22    0   50    0   86    0

To test this assumption, we estimated livestock detectability using a single-season occupancy model (Royle and Dorazio, 2008). From the aerial survey, we obtained the presence or absence of livestock (cattle, sheep, goats, camels or donkeys) per segment. We used year as a random effect. We allowed detectability to vary as a function of above ground woody vegetation biomass (WVB) obtained from Bouvet et al. (2018). Because we found significant autocorrelation in the models (Moran’s I test, p-value < 0.01) and autocorrelograms based on 999 simulations showed evidence of high autocorrelation for all years (Fig. 1C), we incorporated a spatial auto-covariate structure in the model (Royle and Dorazio, 2008). We used a 4 neighborhood structure for the auto-covariate specification.

We implemented models using program OpenBUGS and JAGS, through packages R2OpenBUGS and jagsUI in R programing language (R Development Core Team, 2016). We ran 3 parallel Markov chain Monte Carlo (MCMC) chains to find 30,000 samples of the parameters of interest after a 10,000 burn-in period and a 1:10 thinning rate. Non-informative priors were used in all cases.

Estimate livestock detection probability

#Create detection history for livestock
detectionsDom<-data.frame()
for (y in 1:Y){
  for (i in 1:length(SpListDom)){
    dat0<-subset(detdom, Year==Years[y])
    dat1<-subset(dat0, Species==SpListDom[i])
    for (j in 1:J){
      dat2<-subset(dat1, Cell==j)
      dat3<-as.data.frame(t(dat2[-1]))
      dat4<-data.frame(Species=SpListDom[i], Year=Years[y], X1=dat3[1,1],X2=dat3[1,2])
      detectionsDom<-rbind(detectionsDom, dat4)
    }
  }
}

DomDetHist <- array(NA,dim=c(J,I,4,Y))
dimnames(DomDetHist)[[3]] <- unique(detdom$Species)
dimnames(DomDetHist)[[4]] <- unique(detdom$Year)

for (y in 1:dim(DomDetHist)[4]){
  dat0<-subset(detectionsDom, Year==Years[y])
  for (i in 1:dim(DomDetHist)[3]){
    dat1<-subset(dat0, Species==SpListDom[i])
    DomDetHist[,,i,y]<-as.matrix(dat1[,-(1:2)])
  }
}

##Combine four species
domY<-array(NA, dim=c(J,I,Y))
dimnames(domY)[[3]] <- unique(detdom$Year)
for (y in 1:8){
  Dom1<-DomDetHist[,,,y]
  Dom2<-matrix(mapply(sum, Dom1[,,1], Dom1[,,2], Dom1[,,3], Dom1[,,4], MoreArgs=list(na.rm=T)),ncol=2)
  domY[,,y]<-replace(Dom2,which(Dom2>0),1)
}

#Covariable for detectability
COV<-as.matrix(segcovar)
sd.COV<-sd(c(COV),na.rm=T)
mean.COV<-mean(c(COV),na.rm=T)
COVs <- (COV - mean.COV) / sd.COV #Standarize covariate

#############################################################
#############################################################

# Compute the neighborhood (2nd order)
#We suppose the neighbors are the quadrats immediately to the north, south,
#east and west, so a site has a maximum of 4 neighbors.

neigh <- dnearneigh(newcoord2, d1 = 0, d2 = 5000)

# Store the neighborhood in the format needed by the BUGS model
cardneigh <- card(neigh)
adjmat <- matrix(nrow = length(neigh), ncol = max(cardneigh))
for (i in 1:length(neigh)) {
  adjmat[i, 1:cardneigh[i]] <- neigh[[i]]
}

#Calculte number of neighbors
nn <- replace(adjmat,which(adjmat>0),1)
numnn<-apply(nn, 1, sum,na.rm=TRUE)
###################################
## Single-season occupancy model

cat("
    model {
    ## Model
    ## Priors
    
    mean.psi~ dunif(0,1)
    sd.psi ~ dunif(0,8)
    tau.psi <- pow(sd.psi,-2)

    mean.p~ dunif(0,1)
    sd.p ~ dunif(0,8)
    tau.p <- pow(sd.p,-2)

    for (t in 1:Y){
      psi0[t] ~ dnorm(mean.psi,tau.psi)
      p0[t] ~ dnorm(mean.p,tau.p)
    }
    pcov ~ dnorm(0, 0.01)

    #State process
    for(i in 1:nsite) {
     for (t in 1:Y) {
    z[i,t] ~ dbern(psi[i,t])
    logit(psi[i,t]) <- psi0[t]
    
    # Detection process
    
    for(j in 1:nrep){
    logit(p[i,j,t]) <- p0[t] + pcov * COV[i,j]
    mu.p[i,j,t] <- p[i,j,t]*z[i,t]   
    y[i,j,t] ~ dbern(mu.p[i,j,t])
    }
    
    yres[i,t] <- psi[i,t]-z[i,t]
    }
  }
}
",file="occmodeltime.txt")


occDatat <- list(
  y = domY[,,],
  COV=COV,
  nsite=J,
  nrep=I,
  Y=Y
)
OccPar <- c("mean.p","psi0","p0","pcov","yres")
zst<-array(1,dim=c(J,Y))
OccInit <- function() {
  list(psi0 = runif(8), p0 = runif(8),  pcov = runif(1), z = zst)
}

Occt <- jags(occDatat, OccInit, OccPar,"occmodeltime.txt", n.chains = 3, n.iter = 30000, n.burnin = 10000, n.thin=10,
             parallel = T)

######Moran's I
#Compute Moran I test
#
lw <- nb2listw(neigh, style="B") 
#Run the Monte Carlo simulation with 1000 simulations.
MoranI<-matrix(NA,8)
for (t in 1:8){
    MI<-moran.mc(as.vector(Occt$mean$yres[,t]),lw,nsim=999,zero.policy = NULL)
    p<-MI$p.value
    MoranI[t]<-p
  }

#P > 0.05 i.e., no evidence of spatial autocorrelation

#Plot correlograms
par(mfrow=c(4,1), mar=c(4,4,2,2))
for(i in 1:8) {
    bayres<-correlogram(newcoord2, v = as.vector(Occt$mean$yres[,i]), dist =5000, ns=999, latlong = F)
  }


#Create autologistic model
cat("
    model{
    ## Priors
    
    mean.psi~ dunif(0,1)
    sd.psi ~ dunif(0,8)
    tau.psi <- pow(sd.psi,-2)

    mean.p~ dunif(0,1)
    sd.p ~ dunif(0,8)
    tau.p <- pow(sd.p,-2)

    for (t in 1:Y){
      psi0[t] ~ dnorm(mean.psi,tau.psi)
      p0[t] ~ dnorm(mean.p,tau.p)
    }

    beta~dnorm(0,0.01)
    pcov~dnorm(0,0.01)
    
    ## Model
    # State process
    for(i in 1:nsite) {
     for (t in 1:Y) {
    
      z[i,t] ~ dbern(psi[i,t])
    
      x[i,1,t]<-0
        for(k in 1:numnn[i]){
          x[i,k+1,t]<-x[i,k,t]+z[adjmat[i,k],t]
          }#k
    
    autocov[i,t]<-(x[i,(numnn[i]+1),t]/numnn[i])
    
    logit(psi[i,t])<- psi0[t] + beta*autocov[i,t]
    
    # Detection process
    for(j in 1:nrep){
    logit(p[i,j,t]) <- p0[t] + pcov * COV[i,j]
    p.eff[i,j,t] <- p[i,j,t]*z[i,t] 
    y[i,j,t] ~ dbern(p.eff[i,j,t])
    }#j
    yres[i,t] <- psi[i,t]-z[i,t]
    }#t
    }#i
    }
    ",file="AUToccmodeltime.txt")


##Bugs Data
#For all
OccParaut <- c("mean.p","psi0","p0","pcov","beta","autocov","yres")
zst<-array(1,dim=c(J,Y))
OccInitaut <- function() {
  list(psi0 = runif(8), p0 = runif(8),  pcov = runif(1), beta = runif(1), z = zst)
}
OccDatataut <- list(
  y = domY[,,],
  COV=COV,
  nsite=J,
  nrep=I,
  Y=Y,
  numnn=numnn,
  adjmat=adjmat
)

M <- bugs(OccDatataut, OccInitaut, OccParaut,"AUToccmodeltime.txt", n.chains = 3,n.iter = 30000, n.burnin = 10000, n.thin=10,
            working.directory = getwd(), debug = T)


######Moran's I
#Compute Moran I test
#
lw <- nb2listw(neigh, style="B") 
#Run the Monte Carlo simulation with 1000 simulations.
MoranIauc<-matrix(NA,8)
for (t in 1:8){
  MI<-moran.mc(as.vector(M$mean$yres[,t]),lw,nsim=999,zero.policy = NULL)
  p<-MI$p.value
  MoranIauc[t]<-p
}

#P > 0.05 i.e., no evidence of spatial autocorrelation

#Plot correlograms
par(mfrow=c(4,1), mar=c(4,4,2,2))
for(i in 1:8) {
  bayres<-correlogram(newcoord2, v = as.vector(M$mean$yres[,i]), dist =5000, ns=999, latlong = F)
}
## [1] 0.693
## [1] 0.6592374
## [1] 0.7206927

Model residuals did not show signs of autocorrelation after incorporating the auto-covariate structure (Fig. 4). Mean detection probability for livestock was high (0.69; [95% credible intervals: 0.66 – 0.72]) and not related to woody vegetation biomass (-0.05 [-0.13-0.04]; Fig. 5). Therefore, the probability of detecting at least one livestock in a cell with the two sampling replicates was 〖1-(1-0.69)〗^2 = 0.9039. We concluded that detectability of livestock is high regardless of woody vegetation density. We assumed that livestock counts are a good measure of livestock relative abundance across the study area and that there is no spatial variation given by errors in counting animals that could obscure effects when using livestock counts as a covariate for herbivore species occurrence.

Figure 4. Correlograms showing the spatial correlation for model residuals as a function of distance (m) for occupancy models with (left) and without (right) a spatial auto-covariate specification.

Figure 5. Probability of detection (95% Bayesian Credible Interval) as a function of above ground biomass of woody vegetation for livestock on Laikipia rangelands, Kenya.
P=seq(1,70, by=1)
Pst <- (P - mean.COV) / sd.COV

p.pred.mean <- plogis(mean(M$sims.list$mean.p) + mean(M$sims.list$pcov) * Pst)

M01mc<-cbind(M$sims.list$mean.p, M$sims.list$pcov)

p.predS_mean_dist <- matrix(NA, nrow = nrow(M01mc), ncol = 70)
for (i in 1:nrow(p.predS_mean_dist)){
  p.predS_mean_dist[i,] <- plogis(M01mc[i,1] + M01mc[i,2] * Pst)
}
credible_lowerS <- apply(p.predS_mean_dist, MARGIN = 2, quantile, prob = 0.025)
credible_upperS <- apply(p.predS_mean_dist, MARGIN = 2, quantile, prob = 0.975)

##Code for fig. 5
plot(P, p.pred.mean, type="n", ylim=range(c(0.5,0.8)),
     ylab="Probability of detection (95% CRI)", xlab="Woody vegetation biomass", cex.lab=0.9, cex.axis=0.8)
polygon(c(P, rev(P)), c(credible_lowerS, rev(credible_upperS)), col = "gray", border = NA)


lines(P, plogis(mean(M$sims.list$p0[,1]) + mean(M$sims.list$pcov) * Pst), lty=2, col=34)
lines(P, plogis(mean(M$sims.list$p0[,2]) + mean(M$sims.list$pcov) * Pst), lty=3, col=142)
lines(P, plogis(mean(M$sims.list$p0[,3]) + mean(M$sims.list$pcov) * Pst), lty=4, col=143)
lines(P, plogis(mean(M$sims.list$p0[,4]) + mean(M$sims.list$pcov) * Pst), lty=5, col=259)
lines(P, plogis(mean(M$sims.list$p0[,5]) + mean(M$sims.list$pcov) * Pst), lty=6, col=4)
lines(P, plogis(mean(M$sims.list$p0[,6]) + mean(M$sims.list$pcov) * Pst), lty=2, col=497)
lines(P, plogis(mean(M$sims.list$p0[,7]) + mean(M$sims.list$pcov) * Pst), lty=3, col=109)
lines(P, plogis(mean(M$sims.list$p0[,8]) + mean(M$sims.list$pcov) * Pst), lty=4, col=50)

lines(P, p.pred.mean, lwd=2)

legend(0.8,0.65, legend = c("Mean",2001,2004,2006,2008,2010,2012,2015,2016), lty = c(1,2,3,4,5,6,2,3,4), 
       col = c(1,34,142,143,259,4,497,109,50), lwd = c(2,1,1,1,1,1,1,1,1), cex=0.85)

Model specifications

Multispecies site-occupancy models can be formulated as a hierarchical state-space model that links two binary regression models, one model for the occupancy process of each species and a second model for the observation process conditional on occupancy (Kery and Royle, 2016; Royle and Dorazio, 2008; Zipkin et al., 2009). We considered the history of sightings obtained from the aerial survey for i = 1, 2, …, 15 species at j = 1, 2, …, 288 sites (cells), for the spatial replicates (segments) k = 1 and 2 and over t = 1, 2, …, 8 years. The occupancy status of cells can be modeled as the outcome of a Bernoulli distribution as z(j,i,t) ~ Bern (ψ(j,i,t)) where ψ(j,i,t) is the probability that species i is present at site j in year t. The state variable z(j,i,t) is then conditional to the observation process x(j,k,i,t) for species i at site j for the spatial replicate k and year t, which is also assumed to follow a Bernoulli distribution as x(j,k,i,t) ~ Bern (p(j,k,i,t)* z (j,i,t)) where p(j,k,i,t) is the detection probability of for species i and spatial replicate k for year t, if the species is present at site i. In this model, detectability is zero when the species does not occur on a specific site (i.e., z (j,i,t)=0) (Kery and Royle, 2016; Royle and Dorazio, 2008; Zipkin et al., 2009).

As several species were rarely observed, estimating all parameters would not be possible in a species-specific analysis. For this reason, we used the multispecies occupancy approach that incorporates community hierarchical components into the model (Royle and Dorazio, 2008; Zipkin et al., 2009). We did not incorporate unobserved species into the estimations, important for assessing total species richness in a study system, because it was beyond the scope of our study. In the specification of the model, species-level parameters (intercepts u and v and α and β coefficients for each covariate on occupancy and detection probability respectively) are treated as random effects. We allowed occupancy and detection probability to be influenced by covariates that were incorporated into the model using the logit-link function (Royle and Dorazio, 2008). Following Goijman et al., (2015), we incorporated random time effects on the species-specific intercepts (u and v) to control for potential variation across years due to climatic conditions that could affect species occurrence in subsequent years and different observers during counts across yearly surveys.

Across our study area, there is an association between covariates and the different land uses categories (Table 2; Fig. 6). We tested for a potential association between continuous covariates (distance to water, NDVI and livestock relative abundance) and land uses using a non-parametric analysis of variance, the Kruskal-Wallis test. The null hypothesis is that the continuous covariate and the land uses are not associated. A significant Kruskal-Wallis test indicates that there is an association. We found that all covariates are associated with the land-use categories (Table D1; Fig. D1). This is because wildlife and ranching and wildlife areas have fewer stocking rates than ranching and pastoralist areas. Vegetation productivity, measured as NDVI, is generally higher at wildlife and ranching areas than at wildlife and ranching or pastoralist areas, and the same is true for distance to water. Wildlife and ranching areas have more artificial dams than wildlife and ranching or pastoralist areas which result in areas in higher distances to water for cells in many wildlife and ranching or pastoralist sites. Moreover, several cells (~35%) in our study area include more than one type of land use for which it will be wrong to assign a specific land use type. For these reasons, we modeled occupancy probability as a function of distance to water, NDVI and their quadratic effects and livestock relative abundance, a set of covariates that may be then acting as the proximate causes of wildlife occurrence across the different land uses.

Figure 6. Boxplots showing the relationship between (a) distance to water (m), (b) NDVI, and (c) livestock abundance at four different land uses (Pastoralist, ranching, ranching and wildlife, and wildlife only) for all sites sampled in Laikipia, Kenya.
boxplotCovariates<-rbind(data.frame(LandUse=data$LU100, NDVI=data$NDVI01me_1, LA= AbunDom$`2001`, Year=2001), data.frame(LandUse=data$LU100, NDVI=data$NDVI04me_1, LA= AbunDom$`2004`, Year=2004), data.frame(LandUse=data$LU100, NDVI=data$NDVI06me_1, LA= AbunDom$`2006`, Year=2006), data.frame(LandUse=data$LU100, NDVI=data$NDVI08me_1, LA= AbunDom$`2008`, Year=2008), data.frame(LandUse=data$LU100, NDVI=data$NDVI10me_1, LA= AbunDom$`2010`, Year=2010), data.frame(LandUse=data$LU100, NDVI=data$NDVI12me_1, LA= AbunDom$`2012`, Year=2012), data.frame(LandUse=data$LU100, NDVI=data$NDVI15me_1, LA= AbunDom$`2015`, Year=2015), data.frame(LandUse=data$LU100, NDVI=data$NDVI16me_1, LA= AbunDom$`2016`, Year=2016))
boxplotCovariates<-subset(boxplotCovariates, !LandUse=="MixedFarmi")
boxplotCovariates<-subset(boxplotCovariates, !LandUse=="NA")
boxplotCovariates$LandUse<-factor(boxplotCovariates$LandUse)
boxplotCovariates$Year<-factor(boxplotCovariates$Year)
levels(boxplotCovariates$LandUse) <-c("Pastoralist", "Ranching","Ranching and wildlife","Wildlife only")

boxplot1 <- ggplot(boxplotCovariates, aes(x=LandUse, y=LA)) + geom_boxplot() + facet_wrap (~Year, ncol=4)+
labs(x = "Land use", y = "Livestock abundance \n(number of individuals)") + theme(axis.text.x = element_text(angle=45, hjust=1))+
  theme(axis.text = element_text(size = 10), axis.title = element_text(size = 14), strip.text = element_text(size=12))

boxplot2 <- ggplot(boxplotCovariates, aes(x=LandUse, y=NDVI)) + geom_boxplot() + facet_wrap (~Year, ncol=4)+
 labs(x = "Land use", y = "NDVI") + theme(axis.text.x = element_text(angle=45, hjust=1))+
  theme(axis.text = element_text(size = 10), axis.title = element_text(size = 14), strip.text = element_text(size=12))

boxplotCovariates2<-data.frame(LandUse=data$LU100, DW = data$DistWater)
boxplotCovariates2<-subset(boxplotCovariates2, !LandUse=="MixedFarmi")
boxplotCovariates2<-subset(boxplotCovariates2, !LandUse=="NA")
boxplotCovariates2$LandUse<-factor(boxplotCovariates2$LandUse)
levels(boxplotCovariates2$LandUse) <-c("Pastoralist", "Ranching","Ranching and wildlife","Wildlife only")

boxplot3 <- ggplot(boxplotCovariates2, aes(x=LandUse, y=DW)) + geom_boxplot()+
labs(x = "Land use", y = "Distance to water") + theme(axis.text.x = element_text(angle=45, hjust=1))+
theme(axis.text = element_text(size = 10), axis.title = element_text(size=14))

#Plot figure
grid.arrange(boxplot3 ,boxplot2 , boxplot1 , ncol = 2)

## Standarize covariates

#Distance to Water
sd.DW<-sd(data$DistWater,na.rm=T)
mean.DW<-mean(data$DistWater,na.rm=T)
DW <- (data$DistWater - mean.DW) / sd.DW

#NDVI
sd.NDVI<-sd(as.matrix(data[,15:22]),na.rm=T)
mean.NDVI<-mean(as.matrix(data[,15:22]),na.rm=T)
NDVI01 <- (data$NDVI01me_1 - mean.NDVI) / sd.NDVI
NDVI04 <- (data$NDVI04me_1 - mean.NDVI) / sd.NDVI
NDVI06 <- (data$NDVI06me_1 - mean.NDVI) / sd.NDVI
NDVI08 <- (data$NDVI08me_1 - mean.NDVI) / sd.NDVI
NDVI10 <- (data$NDVI10me_1 - mean.NDVI) / sd.NDVI
NDVI12 <- (data$NDVI12me_1 - mean.NDVI) / sd.NDVI
NDVI15 <- (data$NDVI15me_1 - mean.NDVI) / sd.NDVI
NDVI16 <- (data$NDVI16me_1 - mean.NDVI) / sd.NDVI

NDVI <- as.matrix(data.frame(NDVI01,NDVI04,NDVI06,NDVI08,NDVI10,NDVI12,NDVI15,NDVI16))

#Dom abundance
sd.DA<-sd(as.matrix(AbunDom),na.rm=T)
mean.DA<-mean(as.matrix(AbunDom),na.rm=T)

DA01 <- (AbunDom$`2001` - mean.DA) / sd.DA
DA04 <- (AbunDom$`2004` - mean.DA) / sd.DA
DA06 <- (AbunDom$`2006` - mean.DA) / sd.DA
DA08 <- (AbunDom$`2008` - mean.DA) / sd.DA
DA10 <- (AbunDom$`2010` - mean.DA) / sd.DA
DA12 <- (AbunDom$`2012` - mean.DA) / sd.DA
DA15 <- (AbunDom$`2015` - mean.DA) / sd.DA
DA16 <- (AbunDom$`2016` - mean.DA) / sd.DA

DA <- as.matrix(data.frame(DA01,DA04,DA06,DA08,DA10,DA12,DA15,DA16))

#Covariable for detectability
sd.COV<-sd(c(segcovar),na.rm=T)
mean.COV<-mean(c(segcovar),na.rm=T)
COV <- (segcovar - mean.COV) / sd.COV


#Check correlation among covariates for each year
forcor01<- data.frame(DW = DW, NDVI=NDVI01, DA01)
cor(forcor01, method ="spearman")
##              DW       NDVI       DA01
## DW   1.00000000 0.06943354 0.05889265
## NDVI 0.06943354 1.00000000 0.12149073
## DA01 0.05889265 0.12149073 1.00000000
##                DW        NDVI         DA04
## DW    1.000000000 -0.04786046 -0.002685415
## NDVI -0.047860464  1.00000000 -0.199985911
## DA04 -0.002685415 -0.19998591  1.000000000
##               DW         NDVI         DA06
## DW    1.00000000 -0.086771481 -0.040799201
## NDVI -0.08677148  1.000000000  0.009371144
## DA06 -0.04079920  0.009371144  1.000000000
##             DW      NDVI      DA08
## DW   1.0000000 0.1152529 0.1030167
## NDVI 0.1152529 1.0000000 0.1243975
## DA08 0.1030167 0.1243975 1.0000000
##               DW       NDVI        DA10
## DW    1.00000000 -0.1751294 -0.07141242
## NDVI -0.17512942  1.0000000  0.10680872
## DA10 -0.07141242  0.1068087  1.00000000
##                DW        NDVI         DA12
## DW    1.000000000 -0.01353994 -0.007107288
## NDVI -0.013539936  1.00000000 -0.238334491
## DA12 -0.007107288 -0.23833449  1.000000000
##               DW       NDVI        DA15
## DW    1.00000000 -0.1243988  0.09277324
## NDVI -0.12439879  1.0000000 -0.14078572
## DA15  0.09277324 -0.1407857  1.00000000
##              DW       NDVI       DA16
## DW    1.0000000 -0.1300181 -0.0716818
## NDVI -0.1300181  1.0000000 -0.1811002
## DA16 -0.0716818 -0.1811002  1.0000000

##      LandUse   n       mean        sd       min         Q1     median        Q3
## 1 Pastoralis 688 -0.0040843 1.1639827 -1.692157 -0.8977277 -0.2419050 0.5060687
## 2   Ranching  64  0.0430137 0.8162524 -1.163684 -0.6517830  0.0187579 0.5046282
## 3 RanchingWi 648 -0.2274239 0.8035536 -1.497625 -0.8637238 -0.3042175 0.2235071
## 4   Wildlife 144  0.8434286 0.9011551 -1.238325  0.1442764  0.8613619 1.6088634
##        max
## 1 3.642824
## 2 2.133252
## 3 2.475859
## 4 2.811990
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 18.927, df = 3, p-value = 0.0002831
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 10.704, df = 3, p-value = 0.01344
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 27.1, df = 3, p-value = 5.609e-06
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 31.504, df = 3, p-value = 6.659e-07
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 20.433, df = 3, p-value = 0.000138
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 18.934, df = 3, p-value = 0.0002821
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 37.12, df = 3, p-value = 4.339e-08
## 
##  Kruskal-Wallis rank sum test
## 
## data:  NDVI by LandUse
## Kruskal-Wallis chi-squared = 26.583, df = 3, p-value = 7.201e-06
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 35.303, df = 3, p-value = 1.051e-07
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 59.029, df = 3, p-value = 9.475e-13
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 64.739, df = 3, p-value = 5.704e-14
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 55.005, df = 3, p-value = 6.848e-12
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 31.182, df = 3, p-value = 7.781e-07
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 45.643, df = 3, p-value = 6.754e-10
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 36.79, df = 3, p-value = 5.096e-08
## 
##  Kruskal-Wallis rank sum test
## 
## data:  LA by LandUse
## Kruskal-Wallis chi-squared = 60.33, df = 3, p-value = 4.997e-13
## 
##  Kruskal-Wallis rank sum test
## 
## data:  DW by LandUse
## Kruskal-Wallis chi-squared = 16.661, df = 3, p-value = 0.0008297

Therefore, we modeled occupancy probability as a function of a set of covariates that may be acting as the proximate causes of wildlife occurrence across the different land uses: distance to water (DW), NDVI and their quadratic effects and livestock relative abundance (LRA). None of these continuous covariates were highly correlated (Pearson p < 0.5) and all were standardized to a zero mean and unit (1) standard deviation.

The occupancy model for species i at site j and year t was:

\(logit(ψ_i,_j,_t) = u_i,_t + α1_1 * DW_j + α2_i*(DW_j)^2 + α3_i*NDVI_j,_t + α4_i*(NDVI_j,_t)^2 + α5_i*LA_j,_t\)

We modeled detectability in a similar way to occupancy, but allowed detectability to be affected by WVB, which was also standardized as above:

\(logit (p_j,_k,_i,_t )=v_i,_t+β_i*WVB_j,_k\)

Species-level parameters are treated as random effects, each governed by community-level hyperparameters. For instance, we assumed that α1i ~ N(μ_α1,σ_α1) followed a normal distribution where μα1 and σα1 are the mean and standard deviation across the herbivore community. Finally, we incorporated the mean group size effect on the hyperparameter governing species-specific detectability by using a linear regression model on the mean and a linear regression model with log link function to constrain the variance as follows (Kery and Royle, 2016):

\(μ_vi=delta0.p+delta1.p*Group size_i\)

\(log (σ_vi )=phi0.p+phi1.p*Group size_i\)

We calculated the proportion of sites occupied (PSO) per species and per year by dividing the estimated occupied sites by the total number of cells. We also calculated site-specific richness for each year by summing the number of estimated species occurrences per cell. We summarized herbivore species richness in relation to land use by extracting species richness estimates for cells that contained only one land use type to avoid issues of ‘mixed’ cells (i.e., cells containing two or more land uses). Finally, we plotted the relationship of estimated cell-specific herbivore species richness against the three covariates and fit smoothing splines for visualizing trends.

We implemented the model using program JAGS (Plummer, 2016), using the jagsUI package in the R programing language (R Development Core Team, 2016). We used independent, un-informative priors for the community-level hyper-parameters. We checked that those parameters provided strong identifiability by calculating the overlap between each prior and its posterior distribution (i.e., tau << 0.35, Gimenez et al., 2009) using the MCMCvis package. Each of the three parallel Markov chain Monte Carlo (MCMC) chains was run for 150,000 iterations, discarding the first 100,000 as burn-in. We thinned the remaining posterior samples at a rate of 1:10. We evaluated model convergence by visually inspecting chain outputs and using the Gelman-Rubin diagnostic (Gelman and Rubin, 1992). We assessed model fit by estimating the discrepancy between the deviance residuals of the observed and simulated data from the fitted model and by calculating the Bayesian p-value, where values larger than 0.95 or smaller than 0.05 indicate poor fit to the data and a value of 0.5 indicates perfect model fit (Broms et al., 2016). We obtained a p-value of 0.56, indicating that the model provided a good fit to the data. We present parameter-effect sizes in terms of the probability of positive or negative relationships, expressed as the percent of posterior draws above or below zero respectively. We used the Moran’s-I test statistic and visual inspection of correlograms to ensure that the residuals of the occupancy models were not strongly autocorrelated, determining that results were robust to potential pseudo-replication given the grid design.

Model

##The model takes 62 hours to run. 


cat("
    model{
    #Define prior distributions for community-level model parameters
    mean.mu.u ~ dunif(0, 1)
    mean.u <- log(mean.mu.u)- log(1-mean.mu.u)
    
    delta0.p ~ dnorm(0, 0.01)
    delta1.p ~ dnorm(0, 0.01)
    
    phi0.p ~ dnorm(0, 0.01)
    phi1.p ~ dnorm(0, 0.01)
    
    mua1 ~ dnorm(0, 0.01)
    mua2 ~ dnorm(0, 0.01)
    mua3 ~ dnorm(0, 0.01)
    mua4 ~ dnorm(0, 0.01)
    mua5 ~ dnorm(0, 0.01)
    mub1 ~ dnorm(0, 0.01)
    
    sd.a1~dunif(0,10)
    tau.a1<-pow(sd.a1,-2)
    sd.a2~dunif(0,10)
    tau.a2<-pow(sd.a2,-2)
    sd.a3~dunif(0,10)
    tau.a3<-pow(sd.a3,-2)
    sd.a4~dunif(0,10)
    tau.a4<-pow(sd.a4,-2)
    sd.a5~dunif(0,10)
    tau.a5<-pow(sd.a5,-2)
    sd.b1~dunif(0,10)
    tau.b1<-pow(sd.b1,-2)
    
    sd.mu.u ~ dunif(0,10)
    tau.mu.u <- pow(sd.mu.u,-2)
    
    for (i in 1:n) {
    
    #Create priors for species i from the community level prior distributions
    #and incorporate group size effect on detectability
    
    mu.u[i] ~ dnorm(mean.u, tau.mu.u)
    sd.u[i] ~ dunif(0,10)
    tau.u[i] <- pow(sd.u[i],-2)

    mu.v[i] ~ dnorm(mean.v[i], tau.mu.v[i])
    mean.v[i] <- delta0.p + delta1.p * grsize[i] 
    log(var.p[i]) <- phi0.p + phi1.p * grsize[i]
    tau.mu.v[i] <- 1/var.p[i]

    sd.v[i] ~ dunif(0,10)
    tau.v[i] <- pow(sd.v[i],-2)

    a1[i] ~ dnorm(mua1, tau.a1)
    a2[i] ~ dnorm(mua2, tau.a2)
    a3[i] ~ dnorm(mua3, tau.a3)
    a4[i] ~ dnorm(mua4, tau.a4)
    a5[i] ~ dnorm(mua5, tau.a5)
    b1[i] ~ dnorm(mub1, tau.b1)
    
    # Incorporate time random effect on the intercepts
    for (t in 1:Y){
        u[i,t] ~ dnorm(mu.u[i],tau.u[i])
        v[i,t] ~ dnorm(mu.v[i],tau.v[i])
        }
    
    # Ecological model for latent occurrence
    for (j in 1:J) {
     for (t in 1:Y) {
            logit(psi[j,i,t]) <- u[i,t] + a1[i]*DW[j] + a2[i]*(DW[j]*DW[j]) + a3[i]*NDVI[j,t] + a4[i]*(NDVI[j,t]*NDVI[j,t]) + a5[i]*DA[j,t]
    Z[j,i,t] ~ dbern(psi[j,i,t])
    
    # Observation model for detection
    for (k in 1:I) {  
    logit(p[j,k,i,t]) <-  v[i,t] + b1[i]*pcov[j,k]
    mu.p[j,k,i,t] <- p[j,k,i,t]*Z[j,i,t]
    X[j,k,i,t] ~ dbern(mu.p[j,k,i,t])
    
    # Calculate observed deviance
    dev[j,k,i,t]<-X[j,k,i,t]*log(mu.p[j,k,i,t])+(1-X[j,k,i,t])*log(1-mu.p[j,k,i,t])
    
    # Predict new observations and compute deviance
    X.new[j,k,i,t] ~ dbern(mu.p[j,k,i,t])
    dev.sim[j,k,i,t]<-X.new[j,k,i,t]*log(mu.p[j,k,i,t])+(1-X.new[j,k,i,t])*log(1-mu.p[j,k,i,t])
    }#k detection
    
    # Calculate residuals
    yres[j,i,t]<-psi[j,i,t]-Z[j,i,t]
    
    }#Y time
    
    }#J site
    
    }#i species
    
    # Estimate Bayesian p-value
    
    sum.dev<-sum(dev[,,,])
    sum.dev.sim<-sum(dev.sim[,,,])
    test<-step(sum.dev.sim - sum.dev)
    
# Create a loop to determine point level richness estimates for the whole 
#community per year.
    for(t in 1:Y){
        for(j in 1:J){
            Nsite[j,t]<- sum(Z[j,1:n,t])
        }
    }
    
# Create loop to calculate proportion of sites occupied per species and per 
#year
    for(i in 1:n){    
        for(t in 1:Y){
            PSO[i,t] <- sum(Z[,i,t])/J
    }
    }
",file="covarmodel_time_splevel.txt")
    
#Load all the data
sp.data.time <- list(
  n=n, 
  J=J, 
  I=I,
  X=DetHist, 
  Y=Y,
  pcov=COV,
  NDVI=NDVI, 
  DA=DA, 
  DW=DW,
  grsize=GroupSize$MeanGrSize
)

#Specify the parameters to be monitored
sp.params.time <- c("mean.u",'mean.v',"mu.u","mu.v","mua1","mua2","mua3","mua4","mua5","mub1","delta0.p","delta1.p","phi0.p","phi1.p",'u',"v",'a1','a2','a3',"a4","a5","b1","Nsite","yres","PAO","sum.dev","sum.dev.sim","test") 

#Specify the initial values
## Initialize z to be sites where at least 1 detection
zst<-array(1,dim=c(J,n,Y))
sp.inits.time <- function() {
  list(Z = zst, 
       delta0.p = rnorm(1),
       delta1.p = rnorm(1),
       phi0.p = rnorm(1),
       phi1.p = rnorm(1),
       mu.u = rnorm(n),
       mu.v = rnorm(n),
       sd.u = runif(n,0.1,10),
       sd.v = runif(n,0.1,10),
       a1 = rnorm(n), 
       a2 = rnorm(n), 
       a3 = rnorm(n), 
       a4 = rnorm(n), 
       a5 = rnorm(n), 
       b1 = rnorm(n)
  )}

#Run the model and call the results ?fit?
model1 <- jags(sp.data.time, sp.inits.time, sp.params.time, "covarmodel_time_splevel.txt", codaOnly=c("Nsite","yres","PAO","sum.dev","sum.dev.sim","test"), parallel = F,
               n.chains=3, n.iter=150000, n.burnin=100000, n.thin=10)

We assessed potential autocorrelation in our multi-species occupancy model using Moran’s I statistics and visual inspection of correlograms. Both methods were evaluated based on 999 simulations. We observed that 32.5% of the individual models presented highly significant autocorrelation based on the Moran’s I test (p-value < 0.01). However, visual inspection of correlograms generally show that autocorrelation was not a problem in the models (Fig. F1). We opted to not incorporate a spatial auto-covariate structure into the multispecies community-occupancy model. All impala models showed signs of high autocorrelation. Therefore, model results for these species should be interpreted with caution as parameter variation for this species is likely higher than estimated.

Table F1. P-values for the Moran I test for the residuals of each species and year model output.
##     2001  2004  2006  2008  2010  2012  2015  2016
## EL 0.006 0.030 0.381 0.089 0.012 0.001 0.006 0.015
## GF 0.001 0.121 0.118 0.057 0.013 0.001 0.005 0.001
## ZB 0.001 0.486 0.001 0.016 0.011 0.016 0.130 0.366
## ZG 0.181 0.719 0.016 0.001 0.027 0.057 0.002 0.001
## TG 0.001 0.065 0.001 0.001 0.037 0.001 0.003 0.068
## GG 0.222 0.015 0.006 0.009 0.114 0.665 0.001 0.011
## KG 0.060 0.733 0.111 0.413 0.173 0.141 0.032 0.921
## IM 0.001 0.003 0.001 0.001 0.001 0.001 0.001 0.013
## BF 0.181 0.210 0.463 0.038 0.975 0.011 0.001 0.021
## ED 0.151 0.518 0.020 0.615 0.128 0.465 0.042 0.073
## OS 0.057 0.560 0.033 0.076 0.110 0.380 0.165 0.263
## WH 0.001 0.184 0.295 0.012 0.024 0.063 0.141 0.256
## OX 0.001 0.003 0.187 0.101 0.865 0.042 0.145 0.001
## WB 0.460 0.775 0.063 0.240 0.001 0.895 0.050 0.992
## GN 0.919 0.583 0.114 0.001 0.985 0.999 0.001 0.001

Results