P <- P_byplot[grepl("Mediterranean Maquis",Unit),][order(Cycle_number,Site)][,Site:=factor(Site)]

Mediterranean Maquis - Richness by camera

Monitoring started in 2014 (5 monitoring cycles), Each site has two types of plots - far or near settlements

There are 15 sites total, each site has 5 sampling points

Let’s first validate the data:

#include rare species in analysis
P.anal <- copy(P) # set a fixed variable name for analysis, if want to switch between data WITH rare #species and data WITHOUT rare species then only change once here
#Validate factors and levels
P.anal$Settlements <- as.factor(P.anal$Settlements)
print("Settlements has 2 levels")
## [1] "Settlements has 2 levels"
print(levels(P.anal$Settlements))
## [1] "Far"  "Near"
P.anal$Subunit <- as.factor(P.anal$Subunit)
print("Subunit has 3 levels")
## [1] "Subunit has 3 levels"
print(levels(P.anal$Subunit))
## [1] "Carmel"  "Galilee" "Judea"
P.anal$Site <- as.factor(P.anal$Site)
print("Site has 15 levels")
## [1] "Site has 15 levels"
print(levels(P.anal$Site))
##  [1] "Aderet"          "Beit Oren"       "Ein Yaakov"      "Givat Yearim"   
##  [5] "Givat Yeshayahu" "Goren"           "Iftach"          "Kerem Maharal"  
##  [9] "Kfar Shamai"     "Kisalon"         "Margaliot"       "Nehusha"        
## [13] "Nir Etzion"      "Ofer"            "Yagur"
P.anal$Transect <- as.factor(P.anal$Transect)
print("Transect has 30 levels")
## [1] "Transect has 30 levels"
print(levels(P.anal$Transect))
##  [1] "Aderet Far"           "Aderet Near"          "Beit Oren Far"       
##  [4] "Beit Oren Near"       "Ein Yaakov Far"       "Ein Yaakov Near"     
##  [7] "Givat Yearim Far"     "Givat Yearim Near"    "Givat Yeshayahu Far" 
## [10] "Givat Yeshayahu Near" "Goren Far"            "Goren Near"          
## [13] "Iftach Far"           "Iftach Near"          "Kerem Maharal Far"   
## [16] "Kerem Maharal Near"   "Kfar Shamai Far"      "Kfar Shamai Near"    
## [19] "Kisalon Far"          "Kisalon Near"         "Margaliot Far"       
## [22] "Margaliot Near"       "Nehusha Far"          "Nehusha Near"        
## [25] "Nir Etzion Far"       "Nir Etzion Near"      "Ofer Far"            
## [28] "Ofer Near"            "Yagur Far"            "Yagur Near"
P.anal$Transect_with_date <- as.factor(P.anal$Transect_with_date)
print("Transect with date has 150 levels")
## [1] "Transect with date has 150 levels"
print(levels(P.anal$Transect_with_date))
##   [1] "Aderet Far_03_10_2017"           "Aderet Far_10_08_2021"          
##   [3] "Aderet Far_10_10_2015"           "Aderet Far_17_07_2012"          
##   [5] "Aderet Far_29_09_2019"           "Aderet Near_03_10_2017"         
##   [7] "Aderet Near_10_08_2021"          "Aderet Near_17_07_2012"         
##   [9] "Aderet Near_22_10_2015"          "Aderet Near_29_09_2019"         
##  [11] "Beit Oren Far_03_06_2015"        "Beit Oren Far_05_11_2019"       
##  [13] "Beit Oren Far_07_07_2017"        "Beit Oren Far_07_08_2021"       
##  [15] "Beit Oren Far_18_06_2012"        "Beit Oren Near_05_11_2019"      
##  [17] "Beit Oren Near_07_07_2017"       "Beit Oren Near_07_08_2021"      
##  [19] "Beit Oren Near_18_06_2012"       "Beit Oren Near_25_06_2015"      
##  [21] "Ein Yaakov Far_03_06_2012"       "Ein Yaakov Far_06_02_2020"      
##  [23] "Ein Yaakov Far_06_07_2021"       "Ein Yaakov Far_11_11_2015"      
##  [25] "Ein Yaakov Far_20_10_2017"       "Ein Yaakov Near_03_06_2012"     
##  [27] "Ein Yaakov Near_06_02_2020"      "Ein Yaakov Near_06_07_2021"     
##  [29] "Ein Yaakov Near_10_11_2015"      "Ein Yaakov Near_20_10_2017"     
##  [31] "Givat Yearim Far_03_07_2015"     "Givat Yearim Far_11_07_2021"    
##  [33] "Givat Yearim Far_15_09_2019"     "Givat Yearim Far_29_07_2017"    
##  [35] "Givat Yearim Far_31_07_2012"     "Givat Yearim Near_11_07_2021"   
##  [37] "Givat Yearim Near_16_09_2019"    "Givat Yearim Near_21_07_2015"   
##  [39] "Givat Yearim Near_29_07_2017"    "Givat Yearim Near_31_07_2012"   
##  [41] "Givat Yeshayahu Far_03_09_2019"  "Givat Yeshayahu Far_16_07_2012" 
##  [43] "Givat Yeshayahu Far_24_08_2017"  "Givat Yeshayahu Far_28_06_2021" 
##  [45] "Givat Yeshayahu Far_31_08_2015"  "Givat Yeshayahu Near_03_09_2019"
##  [47] "Givat Yeshayahu Near_16_07_2012" "Givat Yeshayahu Near_24_08_2017"
##  [49] "Givat Yeshayahu Near_28_06_2021" "Givat Yeshayahu Near_29_08_2015"
##  [51] "Goren Far_03_09_2015"            "Goren Far_14_01_2020"           
##  [53] "Goren Far_17_08_2021"            "Goren Far_20_10_2017"           
##  [55] "Goren Far_22_05_2012"            "Goren Near_03_09_2015"          
##  [57] "Goren Near_14_01_2020"           "Goren Near_17_08_2021"          
##  [59] "Goren Near_20_10_2017"           "Goren Near_22_05_2012"          
##  [61] "Iftach Far_04_11_2017"           "Iftach Far_05_08_2015"          
##  [63] "Iftach Far_09_09_2021"           "Iftach Far_16_04_2020"          
##  [65] "Iftach Far_21_05_2012"           "Iftach Near_04_11_2017"         
##  [67] "Iftach Near_05_08_2015"          "Iftach Near_09_09_2021"         
##  [69] "Iftach Near_16_04_2020"          "Iftach Near_21_05_2012"         
##  [71] "Kerem Maharal Far_01_07_2012"    "Kerem Maharal Far_07_12_2019"   
##  [73] "Kerem Maharal Far_11_08_2017"    "Kerem Maharal Far_19_05_2015"   
##  [75] "Kerem Maharal Far_24_07_2021"    "Kerem Maharal Near_01_07_2012"  
##  [77] "Kerem Maharal Near_07_12_2019"   "Kerem Maharal Near_11_08_2017"  
##  [79] "Kerem Maharal Near_19_05_2015"   "Kerem Maharal Near_23_07_2021"  
##  [81] "Kfar Shamai Far_09_11_2021"      "Kfar Shamai Far_13_07_2015"     
##  [83] "Kfar Shamai Far_24_05_2020"      "Kfar Shamai Far_28_09_2017"     
##  [85] "Kfar Shamai Far_29_04_2012"      "Kfar Shamai Near_09_11_2021"    
##  [87] "Kfar Shamai Near_13_07_2015"     "Kfar Shamai Near_24_05_2020"    
##  [89] "Kfar Shamai Near_28_09_2017"     "Kfar Shamai Near_29_04_2012"    
##  [91] "Kisalon Far_19_07_2015"          "Kisalon Far_19_11_2021"         
##  [93] "Kisalon Far_21_06_2017"          "Kisalon Far_22_10_2019"         
##  [95] "Kisalon Far_30_07_2012"          "Kisalon Near_01_07_2015"        
##  [97] "Kisalon Near_19_11_2021"         "Kisalon Near_21_06_2017"        
##  [99] "Kisalon Near_22_10_2019"         "Kisalon Near_30_07_2012"        
## [101] "Margaliot Far_04_11_2017"        "Margaliot Far_16_03_2020"       
## [103] "Margaliot Far_18_01_2022"        "Margaliot Far_20_09_2015"       
## [105] "Margaliot Far_30_04_2012"        "Margaliot Near_04_11_2017"      
## [107] "Margaliot Near_16_03_2020"       "Margaliot Near_18_01_2022"      
## [109] "Margaliot Near_28_10_2015"       "Margaliot Near_30_04_2012"      
## [111] "Nehusha Far_02_10_2019"          "Nehusha Far_05_09_2017"         
## [113] "Nehusha Far_13_08_2012"          "Nehusha Far_13_09_2015"         
## [115] "Nehusha Far_23_08_2021"          "Nehusha Near_02_10_2019"        
## [117] "Nehusha Near_05_09_2017"         "Nehusha Near_13_08_2012"        
## [119] "Nehusha Near_23_08_2021"         "Nehusha Near_26_09_2015"        
## [121] "Nir Etzion Far_02_06_2015"       "Nir Etzion Far_16_06_2017"      
## [123] "Nir Etzion Far_17_06_2012"       "Nir Etzion Far_25_11_2019"      
## [125] "Nir Etzion Far_26_06_2021"       "Nir Etzion Near_02_06_2015"     
## [127] "Nir Etzion Near_16_06_2017"      "Nir Etzion Near_17_06_2012"     
## [129] "Nir Etzion Near_25_11_2019"      "Nir Etzion Near_26_06_2021"     
## [131] "Ofer Far_02_07_2012"             "Ofer Far_04_01_2022"            
## [133] "Ofer Far_13_05_2017"             "Ofer Far_16_12_2019"            
## [135] "Ofer Far_18_05_2015"             "Ofer Near_02_07_2012"           
## [137] "Ofer Near_04_01_2022"            "Ofer Near_13_05_2017"           
## [139] "Ofer Near_16_12_2019"            "Ofer Near_18_05_2015"           
## [141] "Yagur Far_04_06_2012"            "Yagur Far_10_06_2021"           
## [143] "Yagur Far_23_12_2019"            "Yagur Far_28_06_2015"           
## [145] "Yagur Far_28_08_2017"            "Yagur Near_04_06_2012"          
## [147] "Yagur Near_10_06_2021"           "Yagur Near_23_12_2019"          
## [149] "Yagur Near_28_08_2017"           "Yagur Near_29_10_2015"
print("RICHNESS WITH RARE SPECIES")
## [1] "RICHNESS WITH RARE SPECIES"
plot_alpha_diversity(P, x_val = "Subunit", y_val = "richness", ylab_val = "richness", xlab_val = "Subunit", fill_val = "Subunit")

col_names <- c("Cycle_number",  "Deployment.id_new",    "Unit", "Subunit",  "Site", "Settlements",  "Distance_rescaled", "Lon", "Lat", "year", "rescaled_Time.Diff", "sinus_Monitoring.Time.Diff", "cosinus_Monitoring.Time.Diff", "Transect", "Transect_with_date")

abu_by_spp.Maquis <- all.mammal.abundances[grepl("Mediterranean Maquis",Unit),]
spp <- abu_by_spp.Maquis[,c(27:39)]

# filter out species with zero counts 
print(colSums(spp))
##    Canis aureus     Canis lupus   Capra nubiana  Equus hemionus  Gazella dorcas 
##            6971              44               0               0               0 
## Gazella gazella   Hyaena hyaena  Hystrix indica  Lepus capensis     Meles meles 
##             406             298            3019              10             408 
##   Oryx leucoryx      Sus scrofa   Vulpes vulpes 
##               0           10124            1478
spp <- spp[,.SD,.SDcols = colSums(spp)>0]
spp <- mvabund(spp)

plot(spp ~ P.anal$Subunit, overall.main="raw abundances", transformation = "no")
## Overlapping points were shifted along the y-axis to make them visible.
## 
##  PIPING TO 2nd MVFACTOR

my_cols <- c("blue", "darkgreen", "red")
dotchart(P.anal$richness, ylab = "Subunit",
         groups = P.anal$Subunit, gcolor = my_cols,
         color = my_cols[P.anal$Subunit],
         cex = 0.9,  pch = 1, xlab = "richness")

kable(summary(P.anal[,.(richness, abundance, Subunit, rescaled_Time.Diff, cosinus_Monitoring.Time.Diff, sinus_Monitoring.Time.Diff, Site, Transect, Transect_with_date, Distance_rescaled)]))
richness abundance Subunit rescaled_Time.Diff cosinus_Monitoring.Time.Diff sinus_Monitoring.Time.Diff Site Transect Transect_with_date Distance_rescaled
Min. :0.000 Min. : 0.00 Carmel :376 Min. :-1.8927 Min. :-0.99996 Min. :-0.999990 Goren : 87 Goren Near : 45 Kerem Maharal Far_19_05_2015: 10 Min. :-0.9136
1st Qu.:2.000 1st Qu.: 4.00 Galilee:417 1st Qu.:-0.9172 1st Qu.:-0.83907 1st Qu.:-0.602000 Ein Yaakov : 85 Ein Yaakov Near : 44 Aderet Near_10_08_2021 : 9 1st Qu.:-0.8371
Median :2.000 Median : 10.00 Judea :324 Median :-0.1836 Median :-0.04866 Median : 0.000000 Kfar Shamai: 84 Goren Far : 42 Beit Oren Far_07_07_2017 : 9 Median :-0.6362
Mean :2.569 Mean : 20.37 NA Mean :-0.2623 Mean :-0.08610 Mean : 0.008294 Margaliot : 82 Kfar Shamai Far : 42 Ein Yaakov Far_06_07_2021 : 9 Mean :-0.5033
3rd Qu.:3.000 3rd Qu.: 24.00 NA 3rd Qu.: 0.5940 3rd Qu.: 0.56975 3rd Qu.: 0.733190 Iftach : 79 Kfar Shamai Near: 42 Ein Yaakov Far_11_11_2015 : 9 3rd Qu.:-0.3237
Max. :7.000 Max. :341.00 NA Max. : 1.1755 Max. : 1.00000 Max. : 0.999990 Nir Etzion : 77 Margaliot Near : 42 Ein Yaakov Near_03_06_2012 : 9 Max. : 1.6119
NA NA NA NA NA NA (Other) :623 (Other) :860 (Other) :1062 NA
pairs(P.anal[,lapply(X = .SD,FUN = as.numeric),.SDcols=c("Subunit","sinus_Monitoring.Time.Diff", "cosinus_Monitoring.Time.Diff", "rescaled_Time.Diff","Site","Transect", "Transect_with_date", "Distance_rescaled")])

kable(cor(P.anal[,lapply(X = .SD,FUN = as.numeric),.SDcols=c("Subunit","sinus_Monitoring.Time.Diff", "cosinus_Monitoring.Time.Diff", "rescaled_Time.Diff","Site","Transect", "Transect_with_date", "Distance_rescaled")]))
Subunit sinus_Monitoring.Time.Diff cosinus_Monitoring.Time.Diff rescaled_Time.Diff Site Transect Transect_with_date Distance_rescaled
Subunit 1.0000000 0.0808235 0.1250776 0.0324596 -0.3922386 -0.3901787 -0.3895513 -0.1278084
sinus_Monitoring.Time.Diff 0.0808235 1.0000000 0.0926611 0.0071447 0.0360044 0.0345840 0.0366821 -0.0592206
cosinus_Monitoring.Time.Diff 0.1250776 0.0926611 1.0000000 0.0589309 -0.0782191 -0.0774880 -0.0767999 -0.0119164
rescaled_Time.Diff 0.0324596 0.0071447 0.0589309 1.0000000 -0.0128696 -0.0125757 -0.0165851 -0.0556040
Site -0.3922386 0.0360044 -0.0782191 -0.0128696 1.0000000 0.9983334 0.9977772 0.0211274
Transect -0.3901787 0.0345840 -0.0774880 -0.0125757 0.9983334 1.0000000 0.9994624 -0.0167655
Transect_with_date -0.3895513 0.0366821 -0.0767999 -0.0165851 0.9977772 0.9994624 1.0000000 -0.0171086
Distance_rescaled -0.1278084 -0.0592206 -0.0119164 -0.0556040 0.0211274 -0.0167655 -0.0171086 1.0000000
meanvar.plot(spp, xlab = "mean abundance of a given species across sites", ylab = "variance of the abundance of a given species across sites")

Community analysis using package MVabund

Table of abundances per species by camera ID

abundance_and_cameras <- as.data.table(abu_by_spp.Maquis[,c(5,27:39)])
dim(abundance_and_cameras)
## [1] 1117   14
canisau <- abundance_and_cameras[,2] > 0
sum(canisau)
## [1] 678
canislup <- abundance_and_cameras[,3] > 0
sum(canislup)
## [1] 20
capra <- abundance_and_cameras[,4] > 0
sum(capra)
## [1] 0
Equus <- abundance_and_cameras[,5] > 0
sum(Equus)
## [1] 0
Gazellador <- abundance_and_cameras[,6] > 0
sum(Gazellador)
## [1] 0
Gazellagaz <- abundance_and_cameras[,7] > 0
sum(Gazellagaz)
## [1] 141
Hyaena <- abundance_and_cameras[,8] > 0
sum(Hyaena)
## [1] 153
Hystrix <- abundance_and_cameras[,9] > 0
sum(Hystrix)
## [1] 599
Lepus <- abundance_and_cameras[,10] > 0
sum(Lepus)
## [1] 4
Meles <- abundance_and_cameras[,11] > 0
sum(Meles)
## [1] 178
Oryx <- abundance_and_cameras[,12] > 0
sum(Oryx)
## [1] 0
Sus <- abundance_and_cameras[,13] > 0
sum(Sus)
## [1] 703
Vulpes <- abundance_and_cameras[,14] > 0
sum(Vulpes)
## [1] 394

1117 cameras. Species with a minimum of 20 cameras - Canis aureus, Canis lupus, Gazella gazella, Hyaena hyaena, Hystrix indica, Meles meles, Sus scorfa and Vulpes vulpes

spp_no_rare <- abu_by_spp.Maquis[,27:39]
print(colSums(spp_no_rare))
##    Canis aureus     Canis lupus   Capra nubiana  Equus hemionus  Gazella dorcas 
##            6971              44               0               0               0 
## Gazella gazella   Hyaena hyaena  Hystrix indica  Lepus capensis     Meles meles 
##             406             298            3019              10             408 
##   Oryx leucoryx      Sus scrofa   Vulpes vulpes 
##               0           10124            1478
# filter out species with less than 20 individuals (rare species)
spp_no_rare <- spp_no_rare[,.SD,.SDcols = colSums(spp_no_rare)>=20]
#spp_no_rare <- spp_no_rare[,c(-2,-6)]
spp_no_rare <- mvabund(spp_no_rare)
print(colSums(spp_no_rare))
##    Canis.aureus     Canis.lupus Gazella.gazella   Hyaena.hyaena  Hystrix.indica 
##            6971              44             406             298            3019 
##     Meles.meles      Sus.scrofa   Vulpes.vulpes 
##             408           10124            1478
#Sus scorfa abundance across subunit, sites and projectid
my_cols <- c("blue", "darkgreen", "red")
dotchart(P.anal$`Sus scrofa`, ylab = "Subunit",
         groups = P.anal$Subunit, gcolor = my_cols,
         color = my_cols[P.anal$Subunit],
         cex = 0.9,  pch = 1, xlab = "Abundance")

P.anal$Project.ID <- as.factor(P.anal$Project.ID)
my_cols <- c("blue", "darkgreen", "red", "purple", "darkorange")
dotchart(P.anal$`Sus scrofa`, ylab = "Project.ID",
         groups = P.anal$Project.ID, gcolor = my_cols,
         color = my_cols[P.anal$Project.ID],
         cex = 0.9,  pch = 1, xlab = "Abundance")

fun_color_range <- colorRampPalette(c("#1b98e0", "red"))
my_cols <- fun_color_range(15)    
dotchart(P.anal$`Sus scrofa`, ylab = "Site",
         groups = P.anal$Site, gcolor = my_cols,
         color = my_cols[P.anal$Site],
         cex = 0.9,  pch = 1, xlab = "Abundance")

Species with 20 individuals or more - Canis aureus, Canis lupus, Gazella gazella, Hyaena hyaena, Hystrix indica, Meles meles, Sus scorfa and Vulpes vulpes

Left with 8 species

env_data <- abu_by_spp.Maquis[,..col_names]

mva_m0.po <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff, family = "poisson", data = env_data)

mva_m0.nb <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff, family = "negative.binomial", data = env_data)

aic_dt <- data.table(nb = mva_m0.nb$aic, po=mva_m0.po$aic)
colMeans(aic_dt)
##       nb       po 
## 2979.663 8038.338
print("POISSON")
## [1] "POISSON"
plot(mva_m0.po, which=1:3)

print("NEGATIVE BINOMIAL")
## [1] "NEGATIVE BINOMIAL"
plot(mva_m0.nb, which=1:3)

prefer negative binomial because standardized residuals are smaller.

# mva_m0 <- mva_m0.po
# mva_m1 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + dunes*rescaled_Time.Diff + Distance_rescaled:dunes + cos_td_rad + sin_td_rad + site, family = "poisson", data = env_data)
# aic_dt$po1 <- mva_m1$aic

mva_m0 <- mva_m0.nb
mva_m1 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site + Subunit, data = env_data)
aic_dt$nb1 <- mva_m1$aic
colMeans(aic_dt)
##       nb       po      nb1 
## 2979.663 8038.338 2807.215
mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Transect, data = env_data)
aic_dt$nb2 <- mva_m2$aic
colMeans(aic_dt)
##       nb       po      nb1      nb2 
## 2979.663 8038.338 2807.215 2762.678
mva_m3 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site, data = env_data)
aic_dt$nb3 <- mva_m2$aic
colMeans(aic_dt)
##       nb       po      nb1      nb2      nb3 
## 2979.663 8038.338 2807.215 2762.678 2762.678
mva_m4 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Subunit, data = env_data)
aic_dt$nb4 <- mva_m2$aic
colMeans(aic_dt)
##       nb       po      nb1      nb2      nb3      nb4 
## 2979.663 8038.338 2807.215 2762.678 2762.678 2762.678

Will proceed with subunit:

Many GLM with subunit

mva_m0.nb <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Subunit, family = "negative.binomial", data = env_data)
drop1(mva_m0.nb)
## Single term deletions
## 
## Model:
## spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + 
##     sinus_Monitoring.Time.Diff + Subunit
##                                      Df   AIC
## <none>                                  23014
## cosinus_Monitoring.Time.Diff          8 23051
## sinus_Monitoring.Time.Diff            8 23009
## Subunit                              16 23837
## Distance_rescaled:rescaled_Time.Diff  8 23026

Dropped sin time

# mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + dunes*rescaled_Time.Diff + Distance_rescaled:dunes + cos_td_rad + sin_td_rad, family = "poisson", data = env_data)
mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, family = "negative.binomial", data = env_data)
drop1(mva_m2)
## Single term deletions
## 
## Model:
## spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + 
##     Subunit
##                                      Df   AIC
## <none>                                  23009
## cosinus_Monitoring.Time.Diff          8 23045
## Subunit                              16 23828
## Distance_rescaled:rescaled_Time.Diff  8 23025
# mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + dunes + rescaled_Time.Diff + Distance_rescaled:dunes + cos_td_rad + sin_td_rad, family = "poisson", data = env_data)
# mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site, family = "negative.binomial", data = env_data)
# drop1(mva_m2)
# mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + dunes + rescaled_Time.Diff + Distance_rescaled:dunes + cos_td_rad + sin_td_rad, family = "poisson", data = env_data)
# mva_m2 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + sinus_Monitoring.Time.Diff + Site, family = "negative.binomial", data = env_data)
# drop1(mva_m2)

Model includes Subunit, cosin time difference and the interaction between time and distance from settlement (but see below, final model without interaction)

# mva_m2 <- manyglm(formula = spp_no_rare ~ Dunes*rescaled_Time.Diff + sinus_Monitoring.Time.Diff + Transect_with_date, data = env_data)
 # drop1(mva_m2)
plot(mva_m2, which=1:3)

#summ_m2 <- summary(mva_m2)
#saveRDS(summ_m2, "output/summ_maquis_model_no_subunit_interaction.RDS")
summ_m2 <- readRDS("output/summ_maquis_model_no_subunit_interaction.RDS")
print(summ_m2)
## 
## Test statistics:
##                                      wald value Pr(>wald)    
## (Intercept)                              25.605     0.001 ***
## Distance_rescaled                        13.896     0.001 ***
## rescaled_Time.Diff                        4.126     0.111    
## cosinus_Monitoring.Time.Diff              7.422     0.001 ***
## SubunitGalilee                           14.087     0.001 ***
## SubunitJudea                             24.436     0.001 ***
## Distance_rescaled:rescaled_Time.Diff      5.523     0.007 ** 
## --- 
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Test statistic:  36.73, p-value: 0.001 
## Arguments:
##  Test statistics calculated assuming response assumed to be uncorrelated 
##  P-value calculated using 999 resampling iterations via pit.trap resampling (to account for correlation in testing).
#anov_m2.uni <- anova(mva_m2, p.uni = "adjusted")
#saveRDS(anov_m2.uni, "output/anova_maquis_model_no_subunit_interaction.RDS")
anov_m2.uni <- readRDS("output/anova_maquis_model_no_subunit_interaction.RDS")
print(anov_m2.uni)
## Analysis of Deviance Table
## 
## Model: spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit
## 
## Multivariate test:
##                                      Res.Df Df.diff   Dev Pr(>Dev)    
## (Intercept)                            1116                           
## Distance_rescaled                      1115       1 158.0    0.001 ***
## rescaled_Time.Diff                     1114       1  33.8    0.004 ** 
## cosinus_Monitoring.Time.Diff           1113       1 131.1    0.001 ***
## Subunit                                1111       2 844.9    0.001 ***
## Distance_rescaled:rescaled_Time.Diff   1110       1  32.3    0.004 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Univariate Tests:
##                                      Canis.aureus          Canis.lupus         
##                                               Dev Pr(>Dev)         Dev Pr(>Dev)
## (Intercept)                                                                    
## Distance_rescaled                          89.311    0.001        2.86    0.093
## rescaled_Time.Diff                          2.027    0.704       1.096    0.808
## cosinus_Monitoring.Time.Diff               37.437    0.001       0.075    0.963
## Subunit                                    19.789    0.003      34.104    0.001
## Distance_rescaled:rescaled_Time.Diff         3.32    0.355       0.034    0.979
##                                      Gazella.gazella          Hyaena.hyaena
##                                                  Dev Pr(>Dev)           Dev
## (Intercept)                                                                
## Distance_rescaled                             12.227    0.010         17.54
## rescaled_Time.Diff                             9.135    0.053         0.657
## cosinus_Monitoring.Time.Diff                  40.549    0.001        19.628
## Subunit                                       91.903    0.001        71.141
## Distance_rescaled:rescaled_Time.Diff           3.771    0.346         7.084
##                                               Hystrix.indica         
##                                      Pr(>Dev)            Dev Pr(>Dev)
## (Intercept)                                                          
## Distance_rescaled                       0.002          4.298    0.081
## rescaled_Time.Diff                      0.837         17.427    0.002
## cosinus_Monitoring.Time.Diff            0.002              0    0.999
## Subunit                                 0.001         20.295    0.002
## Distance_rescaled:rescaled_Time.Diff    0.120          9.791    0.050
##                                      Meles.meles          Sus.scrofa         
##                                              Dev Pr(>Dev)        Dev Pr(>Dev)
## (Intercept)                                                                  
## Distance_rescaled                          8.019    0.058      6.114    0.067
## rescaled_Time.Diff                         0.091    0.940       3.27    0.514
## cosinus_Monitoring.Time.Diff               0.231    0.963     31.727    0.001
## Subunit                                   32.585    0.001    572.242    0.001
## Distance_rescaled:rescaled_Time.Diff       0.002    0.979      7.274    0.120
##                                      Vulpes.vulpes         
##                                                Dev Pr(>Dev)
## (Intercept)                                                
## Distance_rescaled                            17.64    0.002
## rescaled_Time.Diff                           0.122    0.940
## cosinus_Monitoring.Time.Diff                 1.497    0.733
## Subunit                                      2.821    0.418
## Distance_rescaled:rescaled_Time.Diff         1.029    0.709
## Arguments:
##  Test statistics calculated assuming uncorrelated response (for faster computation) 
## P-value calculated using 999 iterations via PIT-trap resampling.

Multivariate test shows that subunit, time, distance from settlements and timeXdistance affect species composition

However, the interaction of time by distance from settlements is not significant for any of the species (H. indica is nearly significant). Therefore the manyglm model will be re-run without this interaction.

mva_m3 <- manyglm(formula = spp_no_rare ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, family = "negative.binomial", data = env_data)
plot(mva_m3, which=1:3)

# summ_m3 <- summary(mva_m3)
# saveRDS(summ_m3, "output/summ_maquis_model_no_subunit_interaction_no_distXtime_interaction.RDS")
summ_m3 <- readRDS("output/summ_maquis_model_no_subunit_interaction_no_distXtime_interaction.RDS")
print(summ_m3)
## 
## Test statistics:
##                              wald value Pr(>wald)    
## (Intercept)                      27.542     0.001 ***
## Distance_rescaled                14.745     0.001 ***
## rescaled_Time.Diff                7.183     0.001 ***
## cosinus_Monitoring.Time.Diff      7.292     0.001 ***
## SubunitGalilee                   13.877     0.001 ***
## SubunitJudea                     24.525     0.001 ***
## --- 
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Test statistic:  36.31, p-value: 0.001 
## Arguments:
##  Test statistics calculated assuming response assumed to be uncorrelated 
##  P-value calculated using 999 resampling iterations via pit.trap resampling (to account for correlation in testing).
# anov_m3.uni <- anova(mva_m3, p.uni = "adjusted")
# saveRDS(anov_m3.uni, "output/anova_maquis_model_no_subunit_interaction_no_distXtime_interaction.RDS")
anov_m3.uni <- readRDS("output/anova_maquis_model_no_subunit_interaction_no_distXtime_interaction.RDS")
print(anov_m3.uni)
## Analysis of Deviance Table
## 
## Model: spp_no_rare ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit
## 
## Multivariate test:
##                              Res.Df Df.diff   Dev Pr(>Dev)    
## (Intercept)                    1116                           
## Distance_rescaled              1115       1 158.0    0.001 ***
## rescaled_Time.Diff             1114       1  33.8    0.002 ** 
## cosinus_Monitoring.Time.Diff   1113       1 131.1    0.001 ***
## Subunit                        1111       2 844.9    0.001 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Univariate Tests:
##                              Canis.aureus          Canis.lupus         
##                                       Dev Pr(>Dev)         Dev Pr(>Dev)
## (Intercept)                                                            
## Distance_rescaled                  89.311    0.001        2.86    0.091
## rescaled_Time.Diff                  2.027    0.669       1.096    0.823
## cosinus_Monitoring.Time.Diff       37.437    0.001       0.075    0.960
## Subunit                            19.789    0.005      34.104    0.001
##                              Gazella.gazella          Hyaena.hyaena         
##                                          Dev Pr(>Dev)           Dev Pr(>Dev)
## (Intercept)                                                                 
## Distance_rescaled                     12.227    0.016         17.54    0.004
## rescaled_Time.Diff                     9.135    0.045         0.657    0.878
## cosinus_Monitoring.Time.Diff          40.549    0.001        19.628    0.001
## Subunit                               91.903    0.001        71.141    0.001
##                              Hystrix.indica          Meles.meles         
##                                         Dev Pr(>Dev)         Dev Pr(>Dev)
## (Intercept)                                                              
## Distance_rescaled                     4.298    0.088       8.019    0.059
## rescaled_Time.Diff                   17.427    0.004       0.091    0.955
## cosinus_Monitoring.Time.Diff              0    0.997       0.231    0.960
## Subunit                              20.295    0.003      32.585    0.001
##                              Sus.scrofa          Vulpes.vulpes         
##                                     Dev Pr(>Dev)           Dev Pr(>Dev)
## (Intercept)                                                            
## Distance_rescaled                 6.114    0.073         17.64    0.004
## rescaled_Time.Diff                 3.27    0.502         0.122    0.955
## cosinus_Monitoring.Time.Diff     31.727    0.001         1.497    0.722
## Subunit                         572.242    0.001         2.821    0.416
## Arguments:
##  Test statistics calculated assuming uncorrelated response (for faster computation) 
## P-value calculated using 999 iterations via PIT-trap resampling.
coefp <- merge(data.table(t(coef(mva_m3)/log(2)),keep.rownames=TRUE), data.table(t(anov_m3.uni$uni.p), keep.rownames = TRUE), by = "rn") # coefficients are exponentiated because the link function used for poisson is log -> above 1 is positive and below 1 is negative
# add total species abundance
coefp <- merge(coefp,as.data.table(colSums(spp_no_rare),keep.rownames = TRUE), by.x = "rn", by.y = "V1")

colnames(coefp) <- c("SciName","Intercept.coef","Distance.coef","time_diff.coef","Cosin_time.coef","Galilee.coef","Judea.coef","Intercept.p","Distance.p","time_diff.p","Cosin_time.p","Subunit.p","Species_abundance")

write.csv(coefp, "coefficients_Maquis_no_subunit_interaction.csv")

species with statistically significant coefficients are in red:

  • species affected by distance from settlements are C. aureus, G. gazella, H. hyaena and V. vulpes.
  • Only H. indica has temporal trend.
  • all but V. vulpes are affected by subunit.
  • none have significant interaction between distance from settlements and time.
cs_dt <- coefp[,c(1,3:7)]
cs_dt$Distance.coef <- cell_spec(cs_dt$Distance.coef, color = ifelse(coefp$Distance.p[1:8]<0.05,"red","black"))
cs_dt$time_diff.coef <- cell_spec(cs_dt$time_diff.coef, color = ifelse(coefp$time_diff.p[1:8]<0.05,"red","black"))
cs_dt$Cosin_time.coef <- cell_spec(cs_dt$Cosin_time.coef, color = ifelse(coefp$Cosin_time.p[1:8]<0.05,"red","black"))
cs_dt$Galilee.coef <- cell_spec(cs_dt$Galilee.coef, color = ifelse(coefp$Subunit.p[1:8]<0.05,"red","black"))
cs_dt$Judea.coef <- cell_spec(cs_dt$Judea.coef, color = ifelse(coefp$Subunit.p[1:8]<0.05,"red","black"))
# cs_dt$Distance_time.coef <- cell_spec(cs_dt$Distance_time.coef, color = ifelse(coefp$Distance_time.p[1:8]<0.05,"red","black"))
kbl(cs_dt, escape = F)
SciName Distance.coef time_diff.coef Cosin_time.coef Galilee.coef Judea.coef
Canis.aureus -1.88387839370257 -0.156580763343216 -0.455337821405233 0.45375375692604 -0.53261607744259
Canis.lupus -1.75751330956443 0.779911914974294 1.1289542200543 5.49973797557243 -12.804186761368
Gazella.gazella 3.01724916480767 0.42011157744274 1.20410677977561 2.68048447104102 4.43913559976176
Hyaena.hyaena 0.767537226140323 -0.166686309768509 0.542166891756021 -3.45926298616577 -0.266100320457472
Hystrix.indica -0.0142200960846689 0.31690382189949 -0.103565884124671 0.302856978274791 0.899995936071587
Meles.meles -0.853310024383845 -0.0322503086221652 0.106758969279724 -1.67979778298015 -1.4987953386487
Sus.scrofa -0.40582465729615 0.251844676369404 -0.0039428677825944 1.22236756638403 -4.7751356357561
Vulpes.vulpes 0.801623654109763 0.019087706976841 0.0754528114362572 0.0612128648645308 0.427410215907544
####Canis aureus####

Canis.aureus <- spp_no_rare[,"Canis.aureus"]
glm.Canis.aureus <- glm.nb(formula = Canis.aureus ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
print(summary(glm.Canis.aureus))
## 
## Call:
## glm.nb(formula = Canis.aureus ~ Distance_rescaled + rescaled_Time.Diff + 
##     cosinus_Monitoring.Time.Diff + Subunit, data = env_data, 
##     init.theta = 0.3359648175, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5986  -1.2585  -0.6222   0.0180   3.2512  
## 
## Coefficients:
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                   0.86947    0.11456   7.590 3.21e-14 ***
## Distance_rescaled            -1.30580    0.13216  -9.881  < 2e-16 ***
## rescaled_Time.Diff           -0.10853    0.05112  -2.123  0.03375 *  
## cosinus_Monitoring.Time.Diff -0.31562    0.08028  -3.931 8.44e-05 ***
## SubunitGalilee                0.31452    0.13008   2.418  0.01561 *  
## SubunitJudea                 -0.36918    0.13968  -2.643  0.00822 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.336) family taken to be 1)
## 
##     Null deviance: 1291.9  on 1116  degrees of freedom
## Residual deviance: 1130.1  on 1111  degrees of freedom
## AIC: 5567.1
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.3360 
##           Std. Err.:  0.0172 
## 
##  2 x log-likelihood:  -5553.0890
coef(glm.Canis.aureus)
##                  (Intercept)            Distance_rescaled 
##                    0.8694715                   -1.3058027 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                   -0.1085339                   -0.3156165 
##               SubunitGalilee                 SubunitJudea 
##                    0.3145169                   -0.3691827
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_effect(P.anal = env_data, m = glm.Canis.aureus, eff2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/")

####Hystrix indica####

Hystrix.indica <- spp_no_rare[,"Hystrix.indica"]
glm.Hystrix.indica <- glm.nb(formula = Hystrix.indica ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
coef(glm.Hystrix.indica)
##                  (Intercept)            Distance_rescaled 
##                  0.722421373                 -0.009855424 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                  0.219660866                 -0.071786487 
##               SubunitGalilee                 SubunitJudea 
##                  0.209924303                  0.623829051
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_effect(P.anal = env_data, m = glm.Hystrix.indica, eff2plot = "rescaled_Time.Diff", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/")

####Gazella gazella####

Gazella.gazella <- spp_no_rare[,"Gazella.gazella"]
glm.Gazella.gazella <- glm.nb(formula = Gazella.gazella ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
print(summary(glm.Gazella.gazella))
## 
## Call:
## glm.nb(formula = Gazella.gazella ~ Distance_rescaled + rescaled_Time.Diff + 
##     cosinus_Monitoring.Time.Diff + Subunit, data = env_data, 
##     init.theta = 0.1658310846, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.0936  -0.5509  -0.3702  -0.1936   3.6341  
## 
## Coefficients:
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                   -2.3951     0.2717  -8.817  < 2e-16 ***
## Distance_rescaled              2.0914     0.2344   8.921  < 2e-16 ***
## rescaled_Time.Diff             0.2912     0.1046   2.783  0.00539 ** 
## cosinus_Monitoring.Time.Diff   0.8346     0.1612   5.177 2.26e-07 ***
## SubunitGalilee                 1.8580     0.3713   5.003 5.64e-07 ***
## SubunitJudea                   3.0770     0.3505   8.779  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.1658) family taken to be 1)
## 
##     Null deviance: 569.17  on 1116  degrees of freedom
## Residual deviance: 373.93  on 1111  degrees of freedom
## AIC: 1217.9
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.1658 
##           Std. Err.:  0.0219 
## 
##  2 x log-likelihood:  -1203.9060
coef(glm.Gazella.gazella)
##                  (Intercept)            Distance_rescaled 
##                   -2.3950866                    2.0914002 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                    0.2911998                    0.8346243 
##               SubunitGalilee                 SubunitJudea 
##                    1.8579738                    3.0769769
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_effect(P.anal = env_data, m = glm.Gazella.gazella, eff2plot = "rescaled_Time.Diff", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/")

plot_model_effect(P.anal = env_data, m = glm.Gazella.gazella, eff2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/")

####Hyaena hyaena####

Hyaena.hyaena <- spp_no_rare[,"Hyaena.hyaena"]
glm.Hyaena.hyaena <- glm.nb(formula = Hyaena.hyaena ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
print(summary(glm.Hyaena.hyaena))
## 
## Call:
## glm.nb(formula = Hyaena.hyaena ~ Distance_rescaled + rescaled_Time.Diff + 
##     cosinus_Monitoring.Time.Diff + Subunit, data = env_data, 
##     init.theta = 0.2428941261, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.9437  -0.6479  -0.3296  -0.2111   3.5536  
## 
## Coefficients:
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                  -0.71584    0.14848  -4.821 1.43e-06 ***
## Distance_rescaled             0.53201    0.17492   3.041  0.00235 ** 
## rescaled_Time.Diff           -0.11554    0.09171  -1.260  0.20772    
## cosinus_Monitoring.Time.Diff  0.37580    0.14072   2.671  0.00757 ** 
## SubunitGalilee               -2.39778    0.32634  -7.347 2.02e-13 ***
## SubunitJudea                 -0.18445    0.20546  -0.898  0.36933    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.2429) family taken to be 1)
## 
##     Null deviance: 567.84  on 1116  degrees of freedom
## Residual deviance: 441.69  on 1111  degrees of freedom
## AIC: 1208.2
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.2429 
##           Std. Err.:  0.0371 
## 
##  2 x log-likelihood:  -1194.1680
coef(glm.Hyaena.hyaena)
##                  (Intercept)            Distance_rescaled 
##                   -0.7158389                    0.5320128 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                   -0.1155375                    0.3758026 
##               SubunitGalilee                 SubunitJudea 
##                   -2.3977776                   -0.1844459
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_effect(P.anal = env_data, m = glm.Hyaena.hyaena, eff2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/", y_cutoff = 2.5)

####Vulpes vulpes####

Vulpes.vulpes <- spp_no_rare[,"Vulpes.vulpes"]
glm.Vulpes.vulpes <- glm.nb(formula = Vulpes.vulpes ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
print(summary(glm.Vulpes.vulpes))
## 
## Call:
## glm.nb(formula = Vulpes.vulpes ~ Distance_rescaled + rescaled_Time.Diff + 
##     cosinus_Monitoring.Time.Diff + Subunit, data = env_data, 
##     init.theta = 0.2237462586, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.1299  -0.9167  -0.8663  -0.0627   4.8535  
## 
## Coefficients:
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                   0.41379    0.13328   3.105 0.001904 ** 
## Distance_rescaled             0.55564    0.14873   3.736 0.000187 ***
## rescaled_Time.Diff            0.01323    0.06553   0.202 0.839981    
## cosinus_Monitoring.Time.Diff  0.05230    0.10241   0.511 0.609582    
## SubunitGalilee                0.04243    0.16950   0.250 0.802337    
## SubunitJudea                  0.29626    0.17665   1.677 0.093522 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.2237) family taken to be 1)
## 
##     Null deviance: 835.89  on 1116  degrees of freedom
## Residual deviance: 813.32  on 1111  degrees of freedom
## AIC: 3059.2
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.2237 
##           Std. Err.:  0.0161 
## 
##  2 x log-likelihood:  -3045.1800
coef(glm.Vulpes.vulpes)
##                  (Intercept)            Distance_rescaled 
##                   0.41379411                   0.55564482 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                   0.01323073                   0.05229951 
##               SubunitGalilee                 SubunitJudea 
##                   0.04242898                   0.29625790
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_effect(P.anal = env_data, m = glm.Vulpes.vulpes, eff2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/")

Analyze two species with interaction between time and distance from settlements

Hystrix indica

#####Hystrix indica####

Hystrix.indica <- spp_no_rare[,"Hystrix.indica"]
glm.Hystrix.indica <- glm.nb(formula = Hystrix.indica ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
coef(glm.Hystrix.indica)
##                          (Intercept)                    Distance_rescaled 
##                          0.561177540                         -0.269045539 
##                   rescaled_Time.Diff         cosinus_Monitoring.Time.Diff 
##                          0.007704071                         -0.065554757 
##                       SubunitGalilee                         SubunitJudea 
##                          0.232072645                          0.606275998 
## Distance_rescaled:rescaled_Time.Diff 
##                         -0.387492337
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_interaction(P.anal = env_data, m = glm.Hystrix.indica, eff2plot = "rescaled_Time.Diff", modvar2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",
fontsize=22, pdf_width=160, outpath = "output/maquis/")
## Warning: -0.962252785766932 is outside the observed range of Distance_rescaled

sd_distance <- sd(env_data$Distance_rescaled)
print(sd_distance)
## [1] 0.458914
mean_distance <- mean(env_data$Distance_rescaled)
print(mean_distance)
## [1] -0.5033388
#calculate +/1 1 SD
small_distance <- mean_distance - sd_distance 
large_distance <- mean_distance + sd_distance

#Test whether temporal trend is different from zero
mm_rescaled_time <- emtrends(glm.Hystrix.indica, specs = "Distance_rescaled", var = "rescaled_Time.Diff", type = "response", at = list(Distance_rescaled = c(small_distance,large_distance)))
print(mm_rescaled_time)
##  Distance_rescaled rescaled_Time.Diff.trend     SE  df asymp.LCL asymp.UCL
##            -0.9623                   0.3806 0.0700 Inf     0.243     0.518
##            -0.0444                   0.0249 0.0714 Inf    -0.115     0.165
## 
## Results are averaged over the levels of: Subunit 
## Confidence level used: 0.95
test_results_mm_rescaled_time <- test(mm_rescaled_time, null = 0, adjust = "fdr")
print(test_results_mm_rescaled_time)
##  Distance_rescaled rescaled_Time.Diff.trend     SE  df z.ratio p.value
##            -0.9623                   0.3806 0.0700 Inf   5.439  <.0001
##            -0.0444                   0.0249 0.0714 Inf   0.349  0.7271
## 
## Results are averaged over the levels of: Subunit 
## P value adjustment: fdr method for 2 tests
#Testing whether abundance is higher near or far from settlements
pairwise_distance <- emmeans(object = glm.Hystrix.indica, ~ Distance_rescaled*rescaled_Time.Diff, at = list(Distance_rescaled = c(small_distance,large_distance)))
print(pairwise_distance)
##  Distance_rescaled rescaled_Time.Diff emmean     SE  df asymp.LCL asymp.UCL
##            -0.9623             -0.262  1.005 0.0754 Inf     0.857      1.15
##            -0.0444             -0.262  0.852 0.0770 Inf     0.701      1.00
## 
## Results are averaged over the levels of: Subunit 
## Results are given on the log (not the response) scale. 
## Confidence level used: 0.95
test_results_distance <- test(pairs(pairwise_distance, by="rescaled_Time.Diff"), by=NULL, adjust="fdr")
print(test_results_distance)
##  contrast                                                                      
##  (Distance_rescaled-0.962252785766932) - (Distance_rescaled-0.0444248306413041)
##  rescaled_Time.Diff estimate   SE  df z.ratio p.value
##              -0.262    0.154 0.11 Inf   1.393  0.1635
## 
## Results are averaged over the levels of: Subunit 
## Results are given on the log (not the response) scale.

Hyaena hyaena

#####Hyaena hyaena####

Hyaena.hyaena <- spp_no_rare[,"Hyaena.hyaena"]
glm.Hyaena.hyaena <- glm.nb(formula = Hyaena.hyaena ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Subunit, data = env_data)
coef(glm.Hyaena.hyaena)
##                          (Intercept)                    Distance_rescaled 
##                           -0.9247904                            0.1630534 
##                   rescaled_Time.Diff         cosinus_Monitoring.Time.Diff 
##                           -0.3160072                            0.4196223 
##                       SubunitGalilee                         SubunitJudea 
##                           -2.3879468                           -0.1874808 
## Distance_rescaled:rescaled_Time.Diff 
##                           -0.4406182
coef(mva_m3)
##                              Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                     0.8694697  -6.6380254      -2.3950853
## Distance_rescaled              -1.3058050  -1.2182154       2.0913978
## rescaled_Time.Diff             -0.1085335   0.5405937       0.2911992
## cosinus_Monitoring.Time.Diff   -0.3156161   0.7825314       0.8346232
## SubunitGalilee                  0.3145181   3.8121279       1.8579703
## SubunitJudea                   -0.3691813  -8.8751860       3.0769743
##                              Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                     -0.7158369     0.72242058 -0.75465021
## Distance_rescaled                0.5320163    -0.00985662 -0.59146944
## rescaled_Time.Diff              -0.1155381     0.21966099 -0.02235421
## cosinus_Monitoring.Time.Diff     0.3758015    -0.07178640  0.07399968
## SubunitGalilee                  -2.3977784     0.20992446 -1.16434710
## SubunitJudea                    -0.1844467     0.62382965 -1.03888576
##                                Sus.scrofa Vulpes.vulpes
## (Intercept)                   1.899725810    0.41379300
## Distance_rescaled            -0.281296217    0.55564318
## rescaled_Time.Diff            0.174565427    0.01323059
## cosinus_Monitoring.Time.Diff -0.002732988    0.05229990
## SubunitGalilee                0.847280632    0.04242952
## SubunitJudea                 -3.309871803    0.29625819
plot_model_interaction(P.anal = env_data, m = glm.Hyaena.hyaena, eff2plot = "rescaled_Time.Diff", modvar2plot = "Distance_rescaled", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",
fontsize=22, pdf_width=160, outpath = "output/maquis/")
## Warning: -0.962252785766932 is outside the observed range of Distance_rescaled

sd_distance <- sd(env_data$Distance_rescaled)
print(sd_distance)
## [1] 0.458914
mean_distance <- mean(env_data$Distance_rescaled)
print(mean_distance)
## [1] -0.5033388
#calculate +/1 1 SD
small_distance <- mean_distance - sd_distance 
large_distance <- mean_distance + sd_distance

#Test whether temporal trend is different from zero
mm_rescaled_time <- emtrends(glm.Hyaena.hyaena, specs = "Distance_rescaled", var = "rescaled_Time.Diff", type = "response", at = list(Distance_rescaled = c(small_distance,large_distance)))
print(mm_rescaled_time)
##  Distance_rescaled rescaled_Time.Diff.trend    SE  df asymp.LCL asymp.UCL
##            -0.9623                    0.108 0.123 Inf    -0.134    0.3496
##            -0.0444                   -0.296 0.117 Inf    -0.526   -0.0667
## 
## Results are averaged over the levels of: Subunit 
## Confidence level used: 0.95
test_results_mm_rescaled_time <- test(mm_rescaled_time, null = 0, adjust = "fdr")
print(test_results_mm_rescaled_time)
##  Distance_rescaled rescaled_Time.Diff.trend    SE  df z.ratio p.value
##            -0.9623                    0.108 0.123 Inf   0.876  0.3811
##            -0.0444                   -0.296 0.117 Inf  -2.529  0.0229
## 
## Results are averaged over the levels of: Subunit 
## P value adjustment: fdr method for 2 tests
#Testing whether abundance is higher near or far from settlements
pairwise_distance <- emmeans(object = glm.Hyaena.hyaena, ~ Distance_rescaled*rescaled_Time.Diff, at = list(Distance_rescaled = c(small_distance,large_distance)))
print(pairwise_distance)
##  Distance_rescaled rescaled_Time.Diff emmean    SE  df asymp.LCL asymp.UCL
##            -0.9623             -0.262  -2.00 0.148 Inf     -2.30     -1.71
##            -0.0444             -0.262  -1.75 0.148 Inf     -2.04     -1.46
## 
## Results are averaged over the levels of: Subunit 
## Results are given on the log (not the response) scale. 
## Confidence level used: 0.95
test_results_distance <- test(pairs(pairwise_distance, by="rescaled_Time.Diff"), by=NULL, adjust="fdr")
print(test_results_distance)
##  contrast                                                                      
##  (Distance_rescaled-0.962252785766932) - (Distance_rescaled-0.0444248306413041)
##  rescaled_Time.Diff estimate    SE  df z.ratio p.value
##              -0.262   -0.256 0.172 Inf  -1.483  0.1380
## 
## Results are averaged over the levels of: Subunit 
## Results are given on the log (not the response) scale.

Session information

session_info()
## ─ Session info ───────────────────────────────────────────────────────────────
##  setting  value
##  version  R version 4.2.3 (2023-03-15 ucrt)
##  os       Windows 10 x64 (build 22631)
##  system   x86_64, mingw32
##  ui       RTerm
##  language (EN)
##  collate  Hebrew_Israel.utf8
##  ctype    Hebrew_Israel.utf8
##  tz       Asia/Jerusalem
##  date     2024-04-09
##  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
## 
## ─ Packages ───────────────────────────────────────────────────────────────────
##  package      * version    date (UTC) lib source
##  abind          1.4-7      2017-09-03 [1] R-Forge (R 4.2.3)
##  betareg        3.2-0      2021-02-09 [1] R-Forge (R 4.2.3)
##  boot           1.3-28.1   2022-11-22 [1] CRAN (R 4.2.3)
##  bslib          0.4.2      2022-12-16 [1] CRAN (R 4.2.3)
##  cachem         1.0.7      2023-02-24 [1] CRAN (R 4.2.3)
##  Cairo        * 1.6-0      2022-07-05 [1] CRAN (R 4.2.2)
##  callr          3.7.3      2022-11-02 [1] CRAN (R 4.2.3)
##  car          * 3.1-2      2023-03-30 [1] CRAN (R 4.2.3)
##  carData      * 3.0-5      2022-01-06 [1] CRAN (R 4.2.3)
##  cellranger     1.1.0      2016-07-27 [1] CRAN (R 4.2.3)
##  chron        * 2.3-61     2023-05-02 [1] CRAN (R 4.2.3)
##  cli            3.6.1      2023-03-23 [1] CRAN (R 4.2.3)
##  cluster        2.1.4      2022-08-22 [1] CRAN (R 4.2.3)
##  coda           0.19-4     2020-09-30 [1] CRAN (R 4.2.3)
##  codetools      0.2-19     2023-02-01 [1] CRAN (R 4.2.2)
##  colorspace     2.1-1      2023-03-08 [1] R-Forge (R 4.2.2)
##  crayon         1.5.2      2022-09-29 [1] CRAN (R 4.2.3)
##  curl           5.0.0      2023-01-12 [1] CRAN (R 4.2.3)
##  data.table   * 1.14.8     2023-02-17 [1] CRAN (R 4.2.3)
##  devtools     * 2.4.5      2022-10-11 [1] CRAN (R 4.2.3)
##  digest         0.6.31     2022-12-11 [1] CRAN (R 4.2.3)
##  doParallel     1.0.17     2022-02-07 [1] CRAN (R 4.2.3)
##  dplyr        * 1.1.1      2023-03-22 [1] CRAN (R 4.2.3)
##  ecoCopula    * 1.0.2      2022-03-02 [1] CRAN (R 4.2.3)
##  ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.2.3)
##  emmeans      * 1.8.6      2023-05-11 [1] CRAN (R 4.2.3)
##  estimability   1.4.1      2022-08-05 [1] CRAN (R 4.2.1)
##  evaluate       0.20       2023-01-17 [1] CRAN (R 4.2.3)
##  extrafont    * 0.19       2023-01-18 [1] CRAN (R 4.2.2)
##  extrafontdb    1.0        2012-06-11 [1] CRAN (R 4.2.0)
##  fansi          1.0.4      2023-01-22 [1] CRAN (R 4.2.3)
##  farver         2.1.1      2022-07-06 [1] CRAN (R 4.2.3)
##  fastmap        1.1.1      2023-02-24 [1] CRAN (R 4.2.3)
##  flexmix        2.3-19     2023-03-16 [1] CRAN (R 4.2.3)
##  foreach        1.5.2      2022-02-02 [1] CRAN (R 4.2.3)
##  Formula        1.2-6      2023-02-25 [1] R-Forge (R 4.2.2)
##  fs             1.6.1      2023-02-06 [1] CRAN (R 4.2.3)
##  generics       0.1.3      2022-07-05 [1] CRAN (R 4.2.3)
##  ggplot2      * 3.5.0      2024-02-23 [1] CRAN (R 4.2.3)
##  glm2           1.2.1      2018-08-11 [1] CRAN (R 4.2.0)
##  glue           1.6.2      2022-02-24 [1] CRAN (R 4.2.3)
##  gtable         0.3.3      2023-03-21 [1] CRAN (R 4.2.3)
##  highr          0.10       2022-12-22 [1] CRAN (R 4.2.3)
##  htmltools      0.5.5      2023-03-23 [1] CRAN (R 4.2.3)
##  htmlwidgets    1.6.2      2023-03-17 [1] CRAN (R 4.2.3)
##  httpuv         1.6.9      2023-02-14 [1] CRAN (R 4.2.3)
##  httr           1.4.5      2023-02-24 [1] CRAN (R 4.2.3)
##  insight        0.19.9     2024-03-15 [1] CRAN (R 4.2.3)
##  interactions * 1.1.5      2021-07-02 [1] CRAN (R 4.2.3)
##  iterators      1.0.14     2022-02-05 [1] CRAN (R 4.2.3)
##  jquerylib      0.1.4      2021-04-26 [1] CRAN (R 4.2.3)
##  jsonlite       1.8.4      2022-12-06 [1] CRAN (R 4.2.3)
##  jtools       * 2.2.1      2022-12-02 [1] CRAN (R 4.2.3)
##  kableExtra   * 1.4.0      2024-01-24 [1] CRAN (R 4.2.3)
##  knitr          1.42       2023-01-25 [1] CRAN (R 4.2.3)
##  labeling       0.4.2      2020-10-20 [1] CRAN (R 4.2.0)
##  later          1.3.0      2021-08-18 [1] CRAN (R 4.2.3)
##  lattice      * 0.21-8     2023-04-05 [1] CRAN (R 4.2.3)
##  lifecycle      1.0.3      2022-10-07 [1] CRAN (R 4.2.3)
##  lme4         * 1.1-32     2023-03-14 [1] CRAN (R 4.2.3)
##  lmtest         0.9-40     2022-03-21 [1] CRAN (R 4.2.3)
##  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.2.3)
##  MASS         * 7.3-58.3   2023-03-07 [1] CRAN (R 4.2.3)
##  Matrix       * 1.5-5      2023-04-05 [1] R-Forge (R 4.2.3)
##  memoise        2.0.1      2021-11-26 [1] CRAN (R 4.2.3)
##  mgcv           1.8-42     2023-03-02 [1] CRAN (R 4.2.3)
##  mime           0.12       2021-09-28 [1] CRAN (R 4.2.0)
##  miniUI         0.1.1.1    2018-05-18 [1] CRAN (R 4.2.3)
##  minqa          1.2.5      2022-10-19 [1] CRAN (R 4.2.3)
##  modeltools     0.2-23     2020-03-05 [1] CRAN (R 4.2.0)
##  multcomp       1.4-23     2023-03-09 [1] CRAN (R 4.2.3)
##  munsell        0.5.0      2018-06-12 [1] CRAN (R 4.2.3)
##  mvabund      * 4.2.1      2022-02-16 [1] CRAN (R 4.2.3)
##  mvtnorm        1.2-0      2023-04-05 [1] R-Forge (R 4.2.3)
##  nlme           3.1-162    2023-01-31 [1] CRAN (R 4.2.3)
##  nloptr         2.0.3      2022-05-26 [1] CRAN (R 4.2.3)
##  nnet           7.3-18     2022-09-28 [1] CRAN (R 4.2.3)
##  numDeriv       2022.9-1   2022-09-27 [1] R-Forge (R 4.2.1)
##  ordinal        2022.11-16 2022-11-16 [1] CRAN (R 4.2.3)
##  pander         0.6.5      2022-03-18 [1] CRAN (R 4.2.3)
##  performance  * 0.10.3     2023-04-07 [1] CRAN (R 4.2.3)
##  permute      * 0.9-7      2022-01-27 [1] CRAN (R 4.2.3)
##  pillar         1.9.0      2023-03-22 [1] CRAN (R 4.2.3)
##  pkgbuild       1.4.2.9000 2023-07-11 [1] Github (r-lib/pkgbuild@7048654)
##  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.2.3)
##  pkgload        1.3.2      2022-11-16 [1] CRAN (R 4.2.3)
##  prettyunits    1.1.1      2020-01-24 [1] CRAN (R 4.2.3)
##  processx       3.8.0      2022-10-26 [1] CRAN (R 4.2.3)
##  profvis        0.3.7      2020-11-02 [1] CRAN (R 4.2.3)
##  promises       1.2.0.1    2021-02-11 [1] CRAN (R 4.2.3)
##  ps             1.7.4      2023-04-02 [1] CRAN (R 4.2.3)
##  purrr          1.0.1      2023-01-10 [1] CRAN (R 4.2.3)
##  R6             2.5.1      2021-08-19 [1] CRAN (R 4.2.3)
##  RColorBrewer   1.1-3      2022-04-03 [1] CRAN (R 4.2.0)
##  Rcpp           1.0.10     2023-01-22 [1] CRAN (R 4.2.3)
##  readxl       * 1.4.2      2023-02-09 [1] CRAN (R 4.2.3)
##  remotes        2.4.2      2021-11-30 [1] CRAN (R 4.2.3)
##  rlang        * 1.1.0      2023-03-14 [1] CRAN (R 4.2.3)
##  rmarkdown      2.21       2023-03-26 [1] CRAN (R 4.2.3)
##  rstudioapi     0.14       2022-08-22 [1] CRAN (R 4.2.3)
##  Rttf2pt1       1.3.12     2023-01-22 [1] CRAN (R 4.2.2)
##  sandwich       3.1-0      2023-04-04 [1] R-Forge (R 4.2.3)
##  sass           0.4.5      2023-01-24 [1] CRAN (R 4.2.3)
##  scales         1.3.0      2023-11-28 [1] CRAN (R 4.2.3)
##  sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.2.3)
##  shiny          1.7.4      2022-12-15 [1] CRAN (R 4.2.3)
##  statmod        1.5.0      2023-01-06 [1] CRAN (R 4.2.3)
##  stringi        1.7.12     2023-01-11 [1] CRAN (R 4.2.2)
##  stringr        1.5.0      2022-12-02 [1] CRAN (R 4.2.3)
##  survival       3.5-5      2023-03-12 [1] CRAN (R 4.2.3)
##  svglite        2.1.1      2023-01-10 [1] CRAN (R 4.2.3)
##  systemfonts    1.0.4      2022-02-11 [1] CRAN (R 4.2.3)
##  TH.data        1.1-2      2022-11-07 [1] R-Forge (R 4.2.3)
##  tibble         3.2.1      2023-03-20 [1] CRAN (R 4.2.3)
##  tidyselect     1.2.0      2022-10-10 [1] CRAN (R 4.2.3)
##  tweedie        2.3.5      2022-08-17 [1] CRAN (R 4.2.3)
##  ucminf         1.1-4.1    2022-09-29 [1] CRAN (R 4.2.1)
##  urlchecker     1.0.1      2021-11-30 [1] CRAN (R 4.2.3)
##  usethis      * 2.1.6      2022-05-25 [1] CRAN (R 4.2.3)
##  utf8           1.2.3      2023-01-31 [1] CRAN (R 4.2.3)
##  vctrs          0.6.1      2023-03-22 [1] CRAN (R 4.2.3)
##  vegan        * 2.6-4      2022-10-11 [1] CRAN (R 4.2.3)
##  viridisLite    0.4.1      2022-08-22 [1] CRAN (R 4.2.3)
##  withr          2.5.0      2022-03-03 [1] CRAN (R 4.2.3)
##  xfun           0.38       2023-03-24 [1] CRAN (R 4.2.3)
##  xml2           1.3.3      2021-11-30 [1] CRAN (R 4.2.3)
##  xtable         1.8-6      2020-06-19 [1] R-Forge (R 4.2.3)
##  yaml           2.3.7      2023-01-23 [1] CRAN (R 4.2.3)
##  zoo            1.8-11     2022-09-17 [1] CRAN (R 4.2.3)
## 
##  [1] C:/Users/Ron Chen/AppData/Local/R/win-library/4.2.3
##  [2] C:/Program Files/R/R-4.2.3/library
## 
## ──────────────────────────────────────────────────────────────────────────────