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
Vulpus <- abundance_and_cameras[,14] > 0
sum(Vulpus)
## [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 Vulpus vulpus

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 Vulpus vulpus

Left with 8 species

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

Many GLM with subunit interactions

mva_m0.nb <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff, family = "negative.binomial", data = env_data)
drop1(mva_m0.nb)
## Single term deletions
## 
## Model:
## spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + Subunit * 
##     Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + 
##     sinus_Monitoring.Time.Diff
##                                      Df   AIC
## <none>                                  22814
## cosinus_Monitoring.Time.Diff          8 22853
## sinus_Monitoring.Time.Diff            8 22813
## Distance_rescaled:rescaled_Time.Diff  8 22814
## Distance_rescaled:Subunit            16 22900
## rescaled_Time.Diff:Subunit           16 22924
mva_m1 <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, family = "negative.binomial", data = env_data)
drop1(mva_m1)
## Single term deletions
## 
## Model:
## spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + Subunit * 
##     Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff
##                                      Df   AIC
## <none>                                  22813
## cosinus_Monitoring.Time.Diff          8 22851
## Distance_rescaled:rescaled_Time.Diff  8 22815
## Distance_rescaled:Subunit            16 22897
## rescaled_Time.Diff:Subunit           16 22920
mva_m1 <- manyglm(formula = spp_no_rare ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, family = "negative.binomial", data = env_data)
drop1(mva_m1)
## Single term deletions
## 
## Model:
## spp_no_rare ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + 
##     cosinus_Monitoring.Time.Diff
##                              Df   AIC
## <none>                          22815
## cosinus_Monitoring.Time.Diff  8 22850
## Subunit:Distance_rescaled    16 22912
## Subunit:rescaled_Time.Diff   16 22919

Model includes cosin time, interaction between subunit and time and subunit and distance

plot(mva_m1, which=1:3)

# summ_m1 <- summary(mva_m1)
# saveRDS(summ_m1, "output/summ_maquis_model_with_subunit_interaction.RDS")
summ_m1 <- readRDS("output/summ_maquis_model_with_subunit_interaction.RDS")
print(summ_m1)
## 
## Test statistics:
##                                   wald value Pr(>wald)    
## (Intercept)                           25.768     0.001 ***
## SubunitGalilee                         7.995     0.001 ***
## SubunitJudea                          14.892     0.001 ***
## Distance_rescaled                     12.740     0.001 ***
## rescaled_Time.Diff                     7.723     0.001 ***
## cosinus_Monitoring.Time.Diff           7.453     0.001 ***
## SubunitGalilee:Distance_rescaled       5.768     0.002 ** 
## SubunitJudea:Distance_rescaled        10.044     0.001 ***
## SubunitGalilee:rescaled_Time.Diff      6.877     0.001 ***
## SubunitJudea:rescaled_Time.Diff        7.906     0.001 ***
## --- 
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Test statistic:  34.44, 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_m1.uni <- anova(mva_m1, p.uni = "adjusted")
# saveRDS(anov_m1.uni, "output/anova_maquis_model_with_subunit_interaction.RDS")
anov_m1.uni <- readRDS("output/anova_maquis_model_with_subunit_interaction.RDS")
print(anov_m1.uni)
## Analysis of Deviance Table
## 
## Model: spp_no_rare ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff
## 
## Multivariate test:
##                              Res.Df Df.diff   Dev Pr(>Dev)    
## (Intercept)                    1116                           
## Subunit                        1114       2 863.6    0.001 ***
## Distance_rescaled              1113       1 199.4    0.001 ***
## rescaled_Time.Diff             1112       1  55.7    0.002 ** 
## cosinus_Monitoring.Time.Diff   1111       1  49.2    0.001 ***
## Subunit:Distance_rescaled      1109       2 138.5    0.001 ***
## Subunit:rescaled_Time.Diff     1107       2 135.8    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)                                                            
## Subunit                            36.167    0.001      33.343    0.001
## Distance_rescaled                  92.681    0.001       1.134    0.516
## rescaled_Time.Diff                  6.789    0.077       1.291    0.756
## cosinus_Monitoring.Time.Diff       12.928    0.020       2.367    0.638
## Subunit:Distance_rescaled          19.085    0.005         0.7    0.245
## Subunit:rescaled_Time.Diff         43.537    0.001       4.213    0.462
##                              Gazella.gazella          Hyaena.hyaena         
##                                          Dev Pr(>Dev)           Dev Pr(>Dev)
## (Intercept)                                                                 
## Subunit                               60.391    0.001        92.277    0.001
## Distance_rescaled                     56.968    0.001          9.28    0.027
## rescaled_Time.Diff                    10.739    0.015         0.496    0.893
## cosinus_Monitoring.Time.Diff          25.716    0.001         6.914    0.151
## Subunit:Distance_rescaled              4.176    0.183        12.171    0.011
## Subunit:rescaled_Time.Diff             0.989    0.699           2.5    0.699
##                              Hystrix.indica          Meles.meles         
##                                         Dev Pr(>Dev)         Dev Pr(>Dev)
## (Intercept)                                                              
## Subunit                              22.772    0.001      32.007    0.001
## Distance_rescaled                     0.472    0.516       8.625    0.027
## rescaled_Time.Diff                   17.991    0.007       0.042    0.946
## cosinus_Monitoring.Time.Diff          0.783    0.910       0.252    0.969
## Subunit:Distance_rescaled            41.145    0.001      19.296    0.005
## Subunit:rescaled_Time.Diff            1.771    0.699       3.351    0.616
##                              Sus.scrofa          Vulpes.vulpes         
##                                     Dev Pr(>Dev)           Dev Pr(>Dev)
## (Intercept)                                                            
## Subunit                           582.6    0.001         4.074    0.300
## Distance_rescaled                12.569    0.027        17.674    0.012
## rescaled_Time.Diff               18.183    0.007         0.123    0.946
## cosinus_Monitoring.Time.Diff      0.001    0.978          0.21    0.969
## Subunit:Distance_rescaled        23.227    0.005        18.657    0.006
## Subunit:rescaled_Time.Diff       74.121    0.001         5.291    0.428
## 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_m1)/log(2)),keep.rownames=TRUE), data.table(t(anov_m1.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","Galilee.coef","Judea.coef","Distance.coef","Time_diff.coef","cosin_time.coef","Galilee_distance.coef","Judea_distance.coef","Galilee_time.coef","Judea_time.coef","Intercept.p","Subunit.p","Distance.p","Time_diff.p","Cosin_time.p","Subunit_distance.p","Subunit_time.p","Species_abundance")

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

Canis aureus

#####Canis aureus####

Canis.aureus <- spp_no_rare[,"Canis.aureus"]
glm.Canis.aureus <- glm.nb(formula = Canis.aureus ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
coef(glm.Canis.aureus)
##                       (Intercept)                    SubunitGalilee 
##                         0.7379764                         0.2887068 
##                      SubunitJudea                 Distance_rescaled 
##                        -1.0561383                        -1.0768661 
##                rescaled_Time.Diff      cosinus_Monitoring.Time.Diff 
##                        -0.4959726                        -0.3461529 
##  SubunitGalilee:Distance_rescaled    SubunitJudea:Distance_rescaled 
##                        -0.4936521                        -1.6603072 
## SubunitGalilee:rescaled_Time.Diff   SubunitJudea:rescaled_Time.Diff 
##                         0.7092476                         0.5938064
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Canis.aureus, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

plot_model_interaction(P.anal = env_data, m = glm.Canis.aureus, eff2plot = "rescaled_Time.Diff", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

#Test whether temporal trend is different from zero
print("Test whether temporal trend is different from zero")
## [1] "Test whether temporal trend is different from zero"
mm_rescaled_time <- emtrends(glm.Canis.aureus, specs = "Subunit", var = "rescaled_Time.Diff", type = "response")
print(mm_rescaled_time)
##  Subunit rescaled_Time.Diff.trend     SE  df asymp.LCL asymp.UCL
##  Carmel                   -0.4960 0.0876 Inf   -0.6676    -0.324
##  Galilee                   0.2133 0.0816 Inf    0.0533     0.373
##  Judea                     0.0978 0.0974 Inf   -0.0931     0.289
## 
## Confidence level used: 0.95
test_results_mm_rescaled_time <- test(mm_rescaled_time, null = 0, adjust = "fdr")
print(test_results_mm_rescaled_time)
##  Subunit rescaled_Time.Diff.trend     SE  df z.ratio p.value
##  Carmel                   -0.4960 0.0876 Inf  -5.663  <.0001
##  Galilee                   0.2133 0.0816 Inf   2.613  0.0134
##  Judea                     0.0978 0.0974 Inf   1.004  0.3153
## 
## P value adjustment: fdr method for 3 tests
#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")
## [1] "Test whether spatial trend is different from zero"
mm_rescaled_distance <- emtrends(glm.Canis.aureus, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_rescaled_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                    -1.08 0.159 Inf     -1.39    -0.765
##  Galilee                   -1.57 0.257 Inf     -2.08    -1.066
##  Judea                     -2.74 0.354 Inf     -3.43    -2.043
## 
## Confidence level used: 0.95
test_results_mm_distance <- test(mm_rescaled_distance, null = 0, adjust = "fdr")
print(test_results_mm_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                    -1.08 0.159 Inf  -6.759  <.0001
##  Galilee                   -1.57 0.257 Inf  -6.100  <.0001
##  Judea                     -2.74 0.354 Inf  -7.725  <.0001
## 
## P value adjustment: fdr method for 3 tests
#Compare spatial trends among subunits
print("Compare spatial trends among subunits")
## [1] "Compare spatial trends among subunits"
pairwise_distance <- emmeans(object = glm.Canis.aureus, ~ Subunit*Distance_rescaled)
print(pairwise_distance)
##  Subunit Distance_rescaled emmean     SE  df asymp.LCL asymp.UCL
##  Carmel             -0.503   1.44 0.0919 Inf      1.26      1.62
##  Galilee            -0.503   1.79 0.0889 Inf      1.62      1.97
##  Judea              -0.503   1.06 0.1042 Inf      0.86      1.27
## 
## Results are given on the log (not the response) scale. 
## Confidence level used: 0.95
test_results_distance <- test(pairs(pairwise_distance, by="Distance_rescaled"), by=NULL, adjust="fdr")
print(test_results_distance)
##  contrast         Distance_rescaled estimate    SE  df z.ratio p.value
##  Carmel - Galilee            -0.503   -0.351 0.128 Inf  -2.743  0.0067
##  Carmel - Judea              -0.503    0.376 0.139 Inf   2.711  0.0067
##  Galilee - Judea             -0.503    0.727 0.140 Inf   5.204  <.0001
## 
## Results are given on the log (not the response) scale. 
## P value adjustment: fdr method for 3 tests

Hyaena hyaena

#####Hyaena hyaena####

Hyaena.hyaena <- spp_no_rare[,"Hyaena.hyaena"]
glm.Hyaena.hyaena <- glm.nb(formula = Hyaena.hyaena ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
coef(glm.Hyaena.hyaena)
##                       (Intercept)                    SubunitGalilee 
##                        -0.7137562                        -3.2358901 
##                      SubunitJudea                 Distance_rescaled 
##                        -1.0144970                         0.7266012 
##                rescaled_Time.Diff      cosinus_Monitoring.Time.Diff 
##                        -0.2257527                         0.3383597 
##  SubunitGalilee:Distance_rescaled    SubunitJudea:Distance_rescaled 
##                        -1.6743486                        -1.6604434 
## SubunitGalilee:rescaled_Time.Diff   SubunitJudea:rescaled_Time.Diff 
##                         0.3356996                         0.2708408
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Hyaena.hyaena, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA", fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")
## [1] "Test whether spatial trend is different from zero"
mm_rescaled_distance <- emtrends(glm.Hyaena.hyaena, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_rescaled_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                    0.727 0.184 Inf     0.366    1.0876
##  Galilee                  -0.948 1.096 Inf    -3.096    1.2001
##  Judea                    -0.934 0.519 Inf    -1.951    0.0831
## 
## Confidence level used: 0.95
test_results_mm_distance <- test(mm_rescaled_distance, null = 0, adjust = "fdr")
print(test_results_mm_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                    0.727 0.184 Inf   3.944  0.0002
##  Galilee                  -0.948 1.096 Inf  -0.865  0.3871
##  Judea                    -0.934 0.519 Inf  -1.800  0.1078
## 
## P value adjustment: fdr method for 3 tests
#Compare spatial trends among subunits
print("Compare spatial trends among subunits")
## [1] "Compare spatial trends among subunits"
pairwise_distance <- emmeans(object = glm.Hyaena.hyaena, ~ Subunit*Distance_rescaled)
print(pairwise_distance)
##  Subunit Distance_rescaled emmean    SE  df asymp.LCL asymp.UCL
##  Carmel             -0.503  -1.05 0.138 Inf     -1.32    -0.778
##  Galilee            -0.503  -3.53 0.342 Inf     -4.20    -2.861
##  Judea              -0.503  -1.30 0.161 Inf     -1.61    -0.985
## 
## Results are given on the log (not the response) scale. 
## Confidence level used: 0.95
test_results_distance <- test(pairs(pairwise_distance, by="Distance_rescaled"), by=NULL, adjust="fdr")
print(test_results_distance)
##  contrast         Distance_rescaled estimate    SE  df z.ratio p.value
##  Carmel - Galilee            -0.503     2.48 0.369 Inf   6.719  <.0001
##  Carmel - Judea              -0.503     0.25 0.209 Inf   1.196  0.2316
##  Galilee - Judea             -0.503    -2.23 0.380 Inf  -5.872  <.0001
## 
## Results are given on the log (not the response) scale. 
## P value adjustment: fdr method for 3 tests

Hystrix indica

#####Hystrix indica####

Hystrix.indica <- spp_no_rare[,"Hystrix.indica"]
glm.Hystrix.indica <- glm.nb(formula = Hystrix.indica ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
summary(glm.Hystrix.indica)
## 
## Call:
## glm.nb(formula = Hystrix.indica ~ Subunit * Distance_rescaled + 
##     Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, 
##     data = env_data, init.theta = 0.4028111892, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5583  -1.2303  -0.5464   0.1358   3.1233  
## 
## Coefficients:
##                                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                        0.85541    0.10742   7.963 1.68e-15 ***
## SubunitGalilee                    -0.06300    0.20344  -0.310  0.75679    
## SubunitJudea                      -0.69582    0.23328  -2.983  0.00286 ** 
## Distance_rescaled                  0.32578    0.13876   2.348  0.01889 *  
## rescaled_Time.Diff                 0.30195    0.08675   3.480  0.00050 ***
## cosinus_Monitoring.Time.Diff      -0.19146    0.08162  -2.346  0.01899 *  
## SubunitGalilee:Distance_rescaled  -0.46150    0.28653  -1.611  0.10726    
## SubunitJudea:Distance_rescaled    -2.27715    0.35563  -6.403 1.52e-10 ***
## SubunitGalilee:rescaled_Time.Diff -0.16600    0.12063  -1.376  0.16879    
## SubunitJudea:rescaled_Time.Diff   -0.08044    0.12467  -0.645  0.51880    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.4028) family taken to be 1)
## 
##     Null deviance: 1166.1  on 1116  degrees of freedom
## Residual deviance: 1075.9  on 1107  degrees of freedom
## AIC: 4433.8
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.4028 
##           Std. Err.:  0.0245 
## 
##  2 x log-likelihood:  -4411.7900

Interaction of subunit with time is not significant - will be dropped from H. indica model

glm.Hystrix.indica <- glm.nb(formula = Hystrix.indica ~ Subunit * Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
summary(glm.Hystrix.indica)
## 
## Call:
## glm.nb(formula = Hystrix.indica ~ Subunit * Distance_rescaled + 
##     rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data, 
##     init.theta = 0.4018098414, link = log)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5446  -1.2182  -0.5649   0.1539   3.2922  
## 
## Coefficients:
##                                  Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                       0.82151    0.10519   7.810 5.73e-15 ***
## SubunitGalilee                    0.00744    0.19850   0.037  0.97010    
## SubunitJudea                     -0.65891    0.23035  -2.860  0.00423 ** 
## Distance_rescaled                 0.29731    0.13844   2.148  0.03174 *  
## rescaled_Time.Diff                0.21144    0.04902   4.314 1.61e-05 ***
## cosinus_Monitoring.Time.Diff     -0.15609    0.07729  -2.020  0.04343 *  
## SubunitGalilee:Distance_rescaled -0.42307    0.28597  -1.479  0.13903    
## SubunitJudea:Distance_rescaled   -2.22784    0.35518  -6.272 3.55e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Negative Binomial(0.4018) family taken to be 1)
## 
##     Null deviance: 1164.2  on 1116  degrees of freedom
## Residual deviance: 1076.0  on 1109  degrees of freedom
## AIC: 4431.6
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  0.4018 
##           Std. Err.:  0.0244 
## 
##  2 x log-likelihood:  -4413.5610
coef(glm.Hystrix.indica)
##                      (Intercept)                   SubunitGalilee 
##                      0.821514189                      0.007440017 
##                     SubunitJudea                Distance_rescaled 
##                     -0.658913418                      0.297311123 
##               rescaled_Time.Diff     cosinus_Monitoring.Time.Diff 
##                      0.211444812                     -0.156093288 
## SubunitGalilee:Distance_rescaled   SubunitJudea:Distance_rescaled 
##                     -0.423075330                     -2.227842340
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Hystrix.indica, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")
## [1] "Test whether spatial trend is different from zero"
mm_rescaled_distance <- emtrends(glm.Hystrix.indica, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_rescaled_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                    0.297 0.138 Inf     0.026     0.569
##  Galilee                  -0.126 0.250 Inf    -0.615     0.364
##  Judea                    -1.931 0.326 Inf    -2.570    -1.291
## 
## Confidence level used: 0.95
test_results_distance <- test(mm_rescaled_distance, null = 0, adjust="fdr")
print(test_results_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                    0.297 0.138 Inf   2.148  0.0476
##  Galilee                  -0.126 0.250 Inf  -0.504  0.6146
##  Judea                    -1.931 0.326 Inf  -5.915  <.0001
## 
## P value adjustment: fdr method for 3 tests
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/")

Meles meles

#####Meles meles####

Meles.meles <- spp_no_rare[,"Meles.meles"]
glm.Meles.meles <- glm.nb(formula = Meles.meles ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
coef(glm.Meles.meles)
##                       (Intercept)                    SubunitGalilee 
##                       -0.76042055                       -0.50900866 
##                      SubunitJudea                 Distance_rescaled 
##                       -2.44602759                       -0.67269550 
##                rescaled_Time.Diff      cosinus_Monitoring.Time.Diff 
##                        0.19389911                       -0.02148272 
##  SubunitGalilee:Distance_rescaled    SubunitJudea:Distance_rescaled 
##                        1.52725051                       -2.15632118 
## SubunitGalilee:rescaled_Time.Diff   SubunitJudea:rescaled_Time.Diff 
##                       -0.39715549                       -0.22230256
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Meles.meles, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")
## [1] "Test whether spatial trend is different from zero"
mm_distance<- emtrends(glm.Meles.meles, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                   -0.673 0.261 Inf   -1.1836    -0.162
##  Galilee                   0.855 0.459 Inf   -0.0444     1.753
##  Judea                    -2.829 0.773 Inf   -4.3431    -1.315
## 
## Confidence level used: 0.95
test_results_distance <- test(mm_distance, null = 0, adjust = "fdr")
print(test_results_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                   -0.673 0.261 Inf  -2.581  0.0148
##  Galilee                   0.855 0.459 Inf   1.863  0.0624
##  Judea                    -2.829 0.773 Inf  -3.662  0.0008
## 
## P value adjustment: fdr method for 3 tests

Sus scrofa

####Sus scrofa####

Sus.scrofa <- spp_no_rare[,"Sus.scrofa"]
glm.Sus.scrofa <- glm.nb(formula = Sus.scrofa ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
coef(glm.Sus.scrofa)
##                       (Intercept)                    SubunitGalilee 
##                        1.87496631                        0.83817303 
##                      SubunitJudea                 Distance_rescaled 
##                       -5.38303071                       -0.26524313 
##                rescaled_Time.Diff      cosinus_Monitoring.Time.Diff 
##                        0.10444555                       -0.17401554 
##  SubunitGalilee:Distance_rescaled    SubunitJudea:Distance_rescaled 
##                        0.09849245                       -1.87063640 
## SubunitGalilee:rescaled_Time.Diff   SubunitJudea:rescaled_Time.Diff 
##                       -0.07140282                        1.94737676
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Sus.scrofa, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

sus_distance <- interact_plot(model = glm.Sus.scrofa, data=env_data, pred = Distance_rescaled, modx = Subunit, main.title = "", interval = T,plot.points = F, jitter = c(0.1,0), point.size = 3, cat.pred.point.size = 4, partial.residuals = F, colors = 'Dark2', modxvals = NULL, line.colors = 'black', point.alpha = 0.25)
sus_distance

# as.data.table(sus_distance$data)[Subunit=="Judea",Sus.scrofa]
# 1 - 0.0005676190/0.1249574967

plot_model_interaction(P.anal = env_data, m = glm.Sus.scrofa, eff2plot = "rescaled_Time.Diff", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

interact_plot(model = glm.Sus.scrofa, data=env_data, pred = rescaled_Time.Diff, modx = Subunit, main.title = "", interval = T,plot.points = F, jitter = c(0.1,0), point.size = 3, cat.pred.point.size = 4, partial.residuals = F, colors = 'Dark2', modxvals = NULL, line.colors = 'black', point.alpha = 0.25)

# generate trend of Judea on separate axes
sus_judea_plot <- plot_model_effect(P.anal = env_data, m = glm.Sus.scrofa, eff2plot = "rescaled_Time.Diff", plot_points = FALSE, plot_residuals = FALSE, export_plot = TRUE,
                                    outpath = "output/maquis/", fontname = "Almoni ML v5 AAA", at_list = list(Subunit="Judea"))

file.remove("output/maquis/mammals__Sus.scrofa_rescaled_Time.Diff.pdf")
## [1] TRUE
# sus_judea_plot$layers[[2]]$aes_params$fill <- "#e3e2f0"
# sus_judea_plot$layers[[2]]$aes_params$alpha <- 0.8
sus_judea_plot$layers[[1]]$aes_params$linetype <- 2
sus_judea_plot$layers[[1]]$aes_params$colour <- "#7570b3"
sus_judea_plot$layers[[1]]$aes_params$linewidth <- 1.5
Cairo(file = paste0("output/maquis/","mammals__Sus.scrofa_rescaled_Time.Diff_Judea_only.pdf"), width = 160, height = 160*2/3, type = "PDF", units = "mm")
print(sus_judea_plot)

dev.off()
## png 
##   2
#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")

## [1] "Test whether spatial trend is different from zero"
mm_rescaled_distance <- emtrends(glm.Sus.scrofa, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_rescaled_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                   -0.265 0.115 Inf    -0.491   -0.0393
##  Galilee                  -0.167 0.200 Inf    -0.558    0.2249
##  Judea                    -2.136 0.623 Inf    -3.357   -0.9147
## 
## Confidence level used: 0.95
test_results_mm_distance <- test(mm_rescaled_distance, null = 0, adjust = "fdr")
print(test_results_mm_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                   -0.265 0.115 Inf  -2.301  0.0321
##  Galilee                  -0.167 0.200 Inf  -0.834  0.4041
##  Judea                    -2.136 0.623 Inf  -3.428  0.0018
## 
## P value adjustment: fdr method for 3 tests
#Test whether temporal trend is different from zero
print("Test whether temporal trend is different from zero")
## [1] "Test whether temporal trend is different from zero"
mm_rescaled_time <- emtrends(glm.Sus.scrofa, specs = "Subunit", var = "rescaled_Time.Diff", type = "response")
print(mm_rescaled_time)
##  Subunit rescaled_Time.Diff.trend     SE  df asymp.LCL asymp.UCL
##  Carmel                     0.104 0.0695 Inf   -0.0317     0.241
##  Galilee                    0.033 0.0653 Inf   -0.0949     0.161
##  Judea                      2.052 0.3233 Inf    1.4182     2.685
## 
## Confidence level used: 0.95
test_results_mm_rescaled_time <- test(mm_rescaled_time, null = 0, adjust = "fdr")
print(test_results_mm_rescaled_time)
##  Subunit rescaled_Time.Diff.trend     SE  df z.ratio p.value
##  Carmel                     0.104 0.0695 Inf   1.504  0.1990
##  Galilee                    0.033 0.0653 Inf   0.506  0.6127
##  Judea                      2.052 0.3233 Inf   6.347  <.0001
## 
## P value adjustment: fdr method for 3 tests

Vulpes vulpes

#####Vulpes vulpes####

Vulpes.vulpes <- spp_no_rare[,"Vulpes.vulpes"]
glm.Vulpes.vulpes <- glm.nb(formula = Vulpes.vulpes ~ Subunit * Distance_rescaled + Subunit * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff, data = env_data)
## Warning: glm.fit: algorithm did not converge
coef(glm.Vulpes.vulpes)
##                       (Intercept)                    SubunitGalilee 
##                        0.56496673                       -0.70024393 
##                      SubunitJudea                 Distance_rescaled 
##                       -0.63159581                        0.94003503 
##                rescaled_Time.Diff      cosinus_Monitoring.Time.Diff 
##                        0.21422379                        0.01986557 
##  SubunitGalilee:Distance_rescaled    SubunitJudea:Distance_rescaled 
##                       -1.26906026                       -1.73205012 
## SubunitGalilee:rescaled_Time.Diff   SubunitJudea:rescaled_Time.Diff 
##                       -0.32932902                       -0.21039373
coef(mva_m1)
##                                   Canis.aureus Canis.lupus Gazella.gazella
## (Intercept)                          0.7379710 -27.2250631      -2.4859914
## SubunitGalilee                       0.2887180  24.2682149       1.4503002
## SubunitJudea                        -1.0561001  12.3780745       2.9386814
## Distance_rescaled                   -1.0768712   1.1350644       2.6217989
## rescaled_Time.Diff                  -0.4959796  21.0853272       0.5628646
## cosinus_Monitoring.Time.Diff        -0.3461457   0.7561096       0.7631725
## SubunitGalilee:Distance_rescaled    -0.4936408  -2.5477340      -1.4037854
## SubunitJudea:Distance_rescaled      -1.6602494  -0.8556531      -0.9802417
## SubunitGalilee:rescaled_Time.Diff    0.7092584 -20.6510298      -0.3200343
## SubunitJudea:rescaled_Time.Diff      0.5938280 -21.2640594      -0.3190575
##                                   Hyaena.hyaena Hystrix.indica Meles.meles
## (Intercept)                          -0.7137567     0.85541361 -0.76041046
## SubunitGalilee                       -3.2358897    -0.06300426 -0.50901932
## SubunitJudea                         -1.0144966    -0.69582359 -2.44603487
## Distance_rescaled                     0.7266002     0.32577741 -0.67266833
## rescaled_Time.Diff                   -0.2257533     0.30194780  0.19389719
## cosinus_Monitoring.Time.Diff          0.3383593    -0.19146041 -0.02148409
## SubunitGalilee:Distance_rescaled     -1.6743478    -0.46149675  1.52722200
## SubunitJudea:Distance_rescaled       -1.6604428    -2.27715087 -2.15634188
## SubunitGalilee:rescaled_Time.Diff     0.3357001    -0.16599960 -0.39715356
## SubunitJudea:rescaled_Time.Diff       0.2708413    -0.08043878 -0.22230100
##                                    Sus.scrofa Vulpes.vulpes
## (Intercept)                        1.87496831    0.56493814
## SubunitGalilee                     0.83817091   -0.70001232
## SubunitJudea                      -5.38303274   -0.63157362
## Distance_rescaled                 -0.26523514    0.93996114
## rescaled_Time.Diff                 0.10444304    0.21421552
## cosinus_Monitoring.Time.Diff      -0.17401890    0.02004382
## SubunitGalilee:Distance_rescaled   0.09848596   -1.26877799
## SubunitJudea:Distance_rescaled    -1.87064515   -1.73195323
## SubunitGalilee:rescaled_Time.Diff -0.07139997   -0.32912464
## SubunitJudea:rescaled_Time.Diff    1.94738139   -0.21045200
plot_model_interaction(P.anal = env_data, m = glm.Vulpes.vulpes, eff2plot = "Distance_rescaled", modvar2plot = "Subunit", plot_points=FALSE, plot_residuals=FALSE, export_plot=TRUE, ylabel = NULL, fontname = "Almoni ML v5 AAA",fontsize=22, pdf_width=160, outpath = "output/maquis/", legend_position = "bottom")

#Test whether spatial trend is different from zero
print("Test whether spatial trend is different from zero")
## [1] "Test whether spatial trend is different from zero"
mm_rescaled_distance <- emtrends(glm.Vulpes.vulpes, specs = "Subunit", var = "Distance_rescaled", type = "response")
print(mm_rescaled_distance)
##  Subunit Distance_rescaled.trend    SE  df asymp.LCL asymp.UCL
##  Carmel                    0.940 0.177 Inf     0.593    1.2874
##  Galilee                  -0.329 0.337 Inf    -0.990    0.3320
##  Judea                    -0.792 0.419 Inf    -1.614    0.0298
## 
## Confidence level used: 0.95
test_results_mm_distance <- test(mm_rescaled_distance, null = 0, adjust = "fdr")
print(test_results_mm_distance)
##  Subunit Distance_rescaled.trend    SE  df z.ratio p.value
##  Carmel                    0.940 0.177 Inf   5.304  <.0001
##  Galilee                  -0.329 0.337 Inf  -0.976  0.3293
##  Judea                    -0.792 0.419 Inf  -1.889  0.0883
## 
## P value adjustment: fdr method for 3 tests

n = 1117 (total number of cameras)

total abundance =

abundance of common species (8 species) = 22,748

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
## 
## ──────────────────────────────────────────────────────────────────────────────