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

Mediterranean Desert Transition Zone - Richness by camera

Monitoring started in 2014 (5 monitoring cycles), Each site as two types of plots - near or far from Settlements. There are 5 sites total - Beit Yatir, Har Amasa, Lahav, Lehavim, Mirsham Each has 5 sampling points except for Mirsham which is missing samples from the first year (2014)

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$Site <- as.factor(P.anal$Site)
print("Site has 5 levels")
## [1] "Site has 5 levels"
print(levels(P.anal$Site))
## [1] "Beit Yatir" "Har Amasa"  "Lahav"      "Lehavim"    "Mirsham"
P.anal$Transect <- as.factor(P.anal$Transect)
print("Transect has 10 levels")
## [1] "Transect has 10 levels"
print(levels(P.anal$Transect))
##  [1] "Beit Yatir Far"  "Beit Yatir Near" "Har Amasa Far"   "Har Amasa Near" 
##  [5] "Lahav Far"       "Lahav Near"      "Lehavim Far"     "Lehavim Near"   
##  [9] "Mirsham Far"     "Mirsham Near"
P.anal$Transect_with_date <- as.factor(P.anal$Transect_with_date)
print("Transect with date has 49 levels - Missing data for Mirsham near in 2014")
## [1] "Transect with date has 49 levels - Missing data for Mirsham near in 2014"
print(levels(P.anal$Transect_with_date))
##  [1] "Beit Yatir Far_03_01_2017"  "Beit Yatir Far_13_07_2014" 
##  [3] "Beit Yatir Far_16_11_2020"  "Beit Yatir Far_20_11_2018" 
##  [5] "Beit Yatir Far_26_02_2023"  "Beit Yatir Near_03_01_2017"
##  [7] "Beit Yatir Near_13_07_2014" "Beit Yatir Near_16_11_2020"
##  [9] "Beit Yatir Near_20_11_2018" "Beit Yatir Near_26_02_2023"
## [11] "Har Amasa Far_16_11_2020"   "Har Amasa Far_17_07_2014"  
## [13] "Har Amasa Far_22_12_2016"   "Har Amasa Far_24_11_2018"  
## [15] "Har Amasa Far_24_11_2022"   "Har Amasa Near_16_11_2020" 
## [17] "Har Amasa Near_17_07_2014"  "Har Amasa Near_22_12_2016" 
## [19] "Har Amasa Near_24_11_2018"  "Har Amasa Near_24_11_2022" 
## [21] "Lahav Far_13_11_2022"       "Lahav Far_20_11_2016"      
## [23] "Lahav Far_25_08_2020"       "Lahav Far_30_07_2014"      
## [25] "Lahav Far_30_10_2018"       "Lahav Near_13_11_2022"     
## [27] "Lahav Near_20_11_2016"      "Lahav Near_25_08_2020"     
## [29] "Lahav Near_30_07_2014"      "Lahav Near_30_10_2018"     
## [31] "Lehavim Far_05_09_2020"     "Lehavim Far_05_11_2016"    
## [33] "Lehavim Far_08_12_2018"     "Lehavim Far_27_11_2022"    
## [35] "Lehavim Far_31_07_2014"     "Lehavim Near_05_09_2020"   
## [37] "Lehavim Near_05_11_2016"    "Lehavim Near_08_12_2018"   
## [39] "Lehavim Near_27_11_2022"    "Lehavim Near_31_07_2014"   
## [41] "Mirsham Far_03_12_2016"     "Mirsham Far_04_08_2014"    
## [43] "Mirsham Far_13_08_2020"     "Mirsham Far_24_02_2023"    
## [45] "Mirsham Far_29_10_2018"     "Mirsham Near_03_12_2016"   
## [47] "Mirsham Near_13_08_2020"    "Mirsham Near_24_02_2023"   
## [49] "Mirsham Near_29_10_2018"
#distance.rescaled <- scale(all.mammal.abundances$Distance)
#write.csv(distance.rescaled, file = "Distance_rescaled.csv")
print("RICHNESS WITH RARE SPECIES")
## [1] "RICHNESS WITH RARE SPECIES"
plot_alpha_diversity(P, x_val = "Settlements", y_val = "richness", ylab_val = "richness", xlab_val = "Settlements", fill_val = "Settlements")

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.MDtransitionalzone <- all.mammal.abundances[grepl("Mediterranean Desert Transition Zone",Unit),]
write.csv(abu_by_spp.MDtransitionalzone, "data_table_MD_tranzitional_zone.csv")
spp <- abu_by_spp.MDtransitionalzone[,27:40]
#spp <- abu_by_spp.MDtransitionalzone[,25:38]
# filter out species with zero counts 
print(colSums(spp))
##      Canis aureus       Canis lupus     Capra nubiana Dama mesopotamica 
##               467                 0                 0                 0 
##    Equus hemionus    Gazella dorcas   Gazella gazella     Hyaena hyaena 
##                 0                 0               940                22 
##    Hystrix indica    Lepus capensis       Meles meles     Oryx leucoryx 
##                97               181                39                 0 
##        Sus scrofa     Vulpes vulpes 
##                 0               708
spp <- spp[,.SD,.SDcols = colSums(spp)>0]
spp <- mvabund(spp)

plot(spp ~ P.anal$Settlements, 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")
dotchart(P.anal$richness, ylab = "Settlements",
         groups = P.anal$Settlements, gcolor = my_cols,
         color = my_cols[P.anal$Settlements],
         cex = 0.9,  pch = 1, xlab = "richness")

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

kable(summary(P.anal[,.(richness, abundance, rescaled_Time.Diff, cosinus_Monitoring.Time.Diff, sinus_Monitoring.Time.Diff, Site, Transect, Transect_with_date, Distance_rescaled)]))
richness abundance rescaled_Time.Diff cosinus_Monitoring.Time.Diff sinus_Monitoring.Time.Diff Site Transect Transect_with_date Distance_rescaled
Min. :1.000 Min. : 1.000 Min. :-1.1972 Min. :-0.99996 Min. :-0.9454 Beit Yatir:64 Beit Yatir Far :34 Mirsham Near_03_12_2016 : 10 Min. :-0.9136
1st Qu.:1.000 1st Qu.: 2.000 1st Qu.:-0.4256 1st Qu.:-0.36729 1st Qu.:-0.8818 Har Amasa :60 Har Amasa Near :31 Beit Yatir Far_26_02_2023: 9 1st Qu.:-0.6122
Median :2.000 Median : 5.000 Median : 0.1810 Median :-0.06634 Median : 0.3959 Lahav :50 Mirsham Near :31 Har Amasa Near_24_11_2022: 9 Median :-0.4099
Mean :2.114 Mean : 8.733 Mean : 0.3403 Mean : 0.02591 Mean : 0.1136 Lehavim :49 Beit Yatir Near:30 Mirsham Near_24_02_2023 : 9 Mean :-0.2132
3rd Qu.:3.000 3rd Qu.:10.000 3rd Qu.: 1.4339 3rd Qu.: 0.58421 3rd Qu.: 0.9333 Mirsham :58 Har Amasa Far :29 Mirsham Near_29_10_2018 : 9 3rd Qu.: 0.1560
Max. :5.000 Max. :89.000 Max. : 1.5246 Max. : 0.99984 Max. : 0.9978 NA Lahav Near :27 Beit Yatir Far_03_01_2017: 8 Max. : 1.2141
NA NA NA NA NA NA (Other) :99 (Other) :227 NA
pairs(P.anal[,lapply(X = .SD,FUN = as.numeric),.SDcols=c("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("sinus_Monitoring.Time.Diff", "cosinus_Monitoring.Time.Diff","rescaled_Time.Diff","Site","Transect", "Transect_with_date", "Distance_rescaled")]))
sinus_Monitoring.Time.Diff cosinus_Monitoring.Time.Diff rescaled_Time.Diff Site Transect Transect_with_date Distance_rescaled
sinus_Monitoring.Time.Diff 1.0000000 0.0471620 -0.2553691 0.2151478 0.2149245 0.1688694 -0.0721399
cosinus_Monitoring.Time.Diff 0.0471620 1.0000000 -0.1553489 -0.0579959 -0.0577145 -0.0685072 -0.1504014
rescaled_Time.Diff -0.2553691 -0.1553489 1.0000000 -0.0123308 -0.0043925 0.0254338 -0.0474549
Site 0.2151478 -0.0579959 -0.0123308 1.0000000 0.9857080 0.9813614 0.0812471
Transect 0.2149245 -0.0577145 -0.0043925 0.9857080 1.0000000 0.9949286 -0.0511837
Transect_with_date 0.1688694 -0.0685072 0.0254338 0.9813614 0.9949286 1.0000000 -0.0450595
Distance_rescaled -0.0721399 -0.1504014 -0.0474549 0.0812471 -0.0511837 -0.0450595 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")

mdl_r.poiss.int <- glm(data = P.anal, formula = richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site + Transect_with_date, family = poisson)
od <- mdl_r.poiss.int$deviance/mdl_r.poiss.int$df.residual
print("Estimating overdispersion parameter phi: (Res. Dev.)/(n-p) where n=number of observations; p=number of parameters in the model.")
## [1] "Estimating overdispersion parameter phi: (Res. Dev.)/(n-p) where n=number of observations; p=number of parameters in the model."
print(paste0('od = ',od))
## [1] "od = 0.401906034280057"

Overdispersion parameter is <1 (underdispersion) and therefore will use Poisson

m0 <- glm(data = P.anal, formula =  richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff, family = poisson)

me0transectwithdate <- glmer(data = P.anal, formula =   richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff +  (1|Transect_with_date), family = poisson, verbose = 1)
## start par. =  1 fn =  931.4645 
## At return
## eval:  15 fn:      850.23888 par:  0.00000
## (NM) 20: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 40: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 60: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 80: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 100: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 120: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 140: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 160: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 180: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 200: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 220: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## boundary (singular) fit: see help('isSingular')
me0transect <- glmer(data = P.anal, formula =   richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff +  (1|Transect), family = poisson, verbose = 1)
## start par. =  1 fn =  880.8692 
## At return
## eval:  14 fn:      850.23888 par:  0.00000
## (NM) 20: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 40: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 60: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 80: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 100: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 120: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 140: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 160: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 180: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 200: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 220: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## boundary (singular) fit: see help('isSingular')
me0site <- glmer(data = P.anal, formula =   richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff +  (1|Site), family = poisson, verbose = 1)
## start par. =  1 fn =  867.4803 
## At return
## eval:  14 fn:      850.23888 par:  0.00000
## (NM) 20: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 40: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 60: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 80: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 100: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 120: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 140: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 160: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 180: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## (NM) 200: f = 850.239 at          0   0.675095   0.073017   0.208805  0.0149138   0.015864 0.00544273
## boundary (singular) fit: see help('isSingular')

All GLMERs result in singular fit, will use regular GLM:

m1 <- step(m0)
## Start:  AIC=862.24
## richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + 
##     sinus_Monitoring.Time.Diff
## 
##                                        Df Deviance    AIC
## - Distance_rescaled:rescaled_Time.Diff  1   132.90 860.24
## - cosinus_Monitoring.Time.Diff          1   132.95 860.29
## - sinus_Monitoring.Time.Diff            1   132.98 860.32
## <none>                                      132.90 862.24
## 
## Step:  AIC=860.24
## richness ~ Distance_rescaled + rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + 
##     sinus_Monitoring.Time.Diff
## 
##                                Df Deviance    AIC
## - cosinus_Monitoring.Time.Diff  1   132.95 858.29
## - sinus_Monitoring.Time.Diff    1   132.98 858.32
## - Distance_rescaled             1   133.75 859.09
## <none>                              132.90 860.24
## - rescaled_Time.Diff            1   150.64 875.98
## 
## Step:  AIC=858.29
## richness ~ Distance_rescaled + rescaled_Time.Diff + sinus_Monitoring.Time.Diff
## 
##                              Df Deviance    AIC
## - sinus_Monitoring.Time.Diff  1   133.03 856.37
## - Distance_rescaled           1   133.75 857.09
## <none>                            132.95 858.29
## - rescaled_Time.Diff          1   150.93 874.27
## 
## Step:  AIC=856.37
## richness ~ Distance_rescaled + rescaled_Time.Diff
## 
##                      Df Deviance    AIC
## - Distance_rescaled   1   133.79 855.13
## <none>                    133.03 856.37
## - rescaled_Time.Diff  1   151.56 872.90
## 
## Step:  AIC=855.13
## richness ~ rescaled_Time.Diff
## 
##                      Df Deviance    AIC
## <none>                    133.79 855.13
## - rescaled_Time.Diff  1   151.99 871.32
# m1 <- glmer(data = P.anal, formula = richness ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + (1|Transect_with_date), family = poisson)
# drop1(m1)
# m2 <- glmer(data = P.anal, formula = richness ~ Distance_rescaled * rescaled_Time.Diff + (1|Transect_with_date), family = poisson)
# drop1(m2)

Final model includes time difference

summ(m1, exp = TRUE, digits=3)
Observations 281
Dependent variable richness
Type Generalized linear model
Family poisson
Link log
χ²(1) 18.194
Pseudo-R² (Cragg-Uhler) 0.066
Pseudo-R² (McFadden) 0.021
AIC 855.130
BIC 862.407
exp(Est.) 2.5% 97.5% z val. p
(Intercept) 1.944 1.772 2.133 14.084 0.000
rescaled_Time.Diff 1.222 1.113 1.340 4.235 0.000
Standard errors: MLE
effect_plot(model = m1, data=P.anal, pred = rescaled_Time.Diff, interval = T, plot.points = F, jitter = c(0.1,0), point.size = 3, cat.pred.point.size = 4, partial.residuals = F, colors = "Qual1", main.title = "Temporal effect (points are partial residuals)")

#m_coef <- coef(m2)
#P.anal$Cycle_number <- as.numeric(P.anal$Cycle_number)
#plot(P.anal$Cycle_number,
 #    exp(m_coef["rescaled_Time.Diff"]*P.anal$rescaled_Time.Diff),
 #xlab = "Cycle number", ylab = "contribution to richness")

Time difference significantly affects species richness

Community analysis using package MVabund

Table of abundances per species by camera ID

abundance_and_cameras <- as.data.table(abu_by_spp.MDtransitionalzone[,c(5,27:40)])
dim(abundance_and_cameras)
## [1] 281  15
canisau <- abundance_and_cameras[,2] > 0
sum(canisau)
## [1] 125
canislup <- abundance_and_cameras[,3] > 0
sum(canislup)
## [1] 0
capra <- abundance_and_cameras[,4] > 0
sum(capra)
## [1] 0
Doma <- abundance_and_cameras[,5] > 0
sum(Doma)
## [1] 0
Equus <- abundance_and_cameras[,6] > 0
sum(Equus)
## [1] 0
Gazellador <- abundance_and_cameras[,7] > 0
sum(Gazellador)
## [1] 0
Gazellagaz <- abundance_and_cameras[,8] > 0
sum(Gazellagaz)
## [1] 112
Hyaena <- abundance_and_cameras[,9] > 0
sum(Hyaena)
## [1] 20
Hystrix <- abundance_and_cameras[,10] > 0
sum(Hystrix)
## [1] 42
Lepus <- abundance_and_cameras[,11] > 0
sum(Lepus)
## [1] 55
Meles <- abundance_and_cameras[,12] > 0
sum(Meles)
## [1] 35
Oryx <- abundance_and_cameras[,13] > 0
sum(Oryx)
## [1] 0
Sus <- abundance_and_cameras[,14] > 0
sum(Sus)
## [1] 0
Vulpus <- abundance_and_cameras[,15] > 0
sum(Vulpus)
## [1] 205

281 cameras More than 20 cameras - Vulpus vulpus, Meles meles, Lepus capensis, Hystrix indica, Hyaena hyaena, Gazella gazella and Canis aureus

spp_no_rare <- abu_by_spp.MDtransitionalzone[,27:40]
#spp_no_rare <- abu_by_spp.MDtransitionalzone[,25:38]
print(colSums(spp_no_rare))
##      Canis aureus       Canis lupus     Capra nubiana Dama mesopotamica 
##               467                 0                 0                 0 
##    Equus hemionus    Gazella dorcas   Gazella gazella     Hyaena hyaena 
##                 0                 0               940                22 
##    Hystrix indica    Lepus capensis       Meles meles     Oryx leucoryx 
##                97               181                39                 0 
##        Sus scrofa     Vulpes vulpes 
##                 0               708
# 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 <- mvabund(spp_no_rare)
print(colSums(spp_no_rare))
##    Canis.aureus Gazella.gazella   Hyaena.hyaena  Hystrix.indica  Lepus.capensis 
##             467             940              22              97             181 
##     Meles.meles   Vulpes.vulpes 
##              39             708

Left with 7 species

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

mva_m0.po <- manyglm(formula =spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site, 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 + Site, 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 
## 590.5388 837.5866
print("POISSON")
## [1] "POISSON"
plot(mva_m0.po, which=1:3)
## Warning in default.plot.manyglm(x, res.type = res.type, which = which, caption
## = caption, : Only the first 7 colors will be used for plotting.

print("NEGATIVE BINOMIAL")
## [1] "NEGATIVE BINOMIAL"
plot(mva_m0.nb, which=1:3)
## Warning in default.plot.manyglm(x, res.type = res.type, which = which, caption
## = caption, : Only the first 7 colors will be used for plotting.

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 + Transect_with_date, data = env_data)
aic_dt$nb1 <- mva_m1$aic
colMeans(aic_dt)
##       nb       po      nb1 
## 590.5388 837.5866 596.8722
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 
## 590.5388 837.5866 596.8722 586.2624
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 
## 590.5388 837.5866 596.8722 586.2624 586.2624

Transect and Site improve the model

##Many GLM with site:

mva_m0.nb <- manyglm(formula = spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + sinus_Monitoring.Time.Diff + Site, 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 + Site
##                                      Df    AIC
## <none>                                  4133.8
## cosinus_Monitoring.Time.Diff          7 4162.7
## sinus_Monitoring.Time.Diff            7 4129.7
## Site                                 28 4293.6
## Distance_rescaled:rescaled_Time.Diff  7 4141.1

Dropped Sin monitoring 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 + Site, 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 + 
##     Site
##                                      Df    AIC
## <none>                                  4129.7
## cosinus_Monitoring.Time.Diff          7 4156.8
## Site                                 28 4292.4
## Distance_rescaled:rescaled_Time.Diff  7 4135.7

Final model includes cosin time, site and the interaction between distance from settlement and time difference.

# 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(spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_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 * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Site, family = "negative.binomial", data = env_data)
# drop1(mva_m2)
plot(mva_m2, which=1:3)
## Warning in default.plot.manyglm(x, res.type = res.type, which = which, caption
## = caption, : Only the first 7 colors will be used for plotting.

# summ_m2 <- summary(mva_m2)
# saveRDS(summ_m2, file = "output/summ_md_zone_999iter.rds")
summ_m2 <- readRDS(file = "output/summ_md_zone_999iter.rds")
print(summ_m2)
## 
## Test statistics:
##                                      wald value Pr(>wald)    
## (Intercept)                              11.708     0.001 ***
## Distance_rescaled                         2.844     0.366    
## rescaled_Time.Diff                       10.298     0.001 ***
## cosinus_Monitoring.Time.Diff              6.435     0.001 ***
## SiteHar Amasa                             4.799     0.003 ** 
## SiteLahav                                 7.012     0.001 ***
## SiteLehavim                               8.936     0.001 ***
## SiteMirsham                               6.585     0.001 ***
## Distance_rescaled:rescaled_Time.Diff      4.488     0.014 *  
## --- 
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Test statistic:  19.12, 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, file = "output/anova_md_zone_999iter.rds")
anov_m2.uni <- readRDS(file = "output/anova_md_zone_999iter.rds")
print(anov_m2.uni)
## Analysis of Deviance Table
## 
## Model: spp_no_rare ~ Distance_rescaled * rescaled_Time.Diff + cosinus_Monitoring.Time.Diff + Site
## 
## Multivariate test:
##                                      Res.Df Df.diff    Dev Pr(>Dev)    
## (Intercept)                             280                            
## Distance_rescaled                       279       1   8.26    0.431    
## rescaled_Time.Diff                      278       1  97.93    0.001 ***
## cosinus_Monitoring.Time.Diff            277       1  41.87    0.001 ***
## Site                                    273       4 217.63    0.001 ***
## Distance_rescaled:rescaled_Time.Diff    272       1  20.02    0.010 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Univariate Tests:
##                                      Canis.aureus          Gazella.gazella
##                                               Dev Pr(>Dev)             Dev
## (Intercept)                                                               
## Distance_rescaled                           7.309    0.098           0.143
## rescaled_Time.Diff                           0.62    0.753          52.311
## cosinus_Monitoring.Time.Diff                0.104    0.941          28.269
## Site                                       37.665    0.001           80.17
## Distance_rescaled:rescaled_Time.Diff       16.132    0.002           1.916
##                                               Hyaena.hyaena         
##                                      Pr(>Dev)           Dev Pr(>Dev)
## (Intercept)                                                         
## Distance_rescaled                       0.992             0    0.994
## rescaled_Time.Diff                      0.001         0.583    0.753
## cosinus_Monitoring.Time.Diff            0.001           0.1    0.941
## Site                                    0.001         2.213    0.750
## Distance_rescaled:rescaled_Time.Diff    0.669         0.034    0.928
##                                      Hystrix.indica          Lepus.capensis
##                                                 Dev Pr(>Dev)            Dev
## (Intercept)                                                                
## Distance_rescaled                             0.278    0.992          0.482
## rescaled_Time.Diff                            2.348    0.413          5.071
## cosinus_Monitoring.Time.Diff                  2.923    0.465          1.416
## Site                                         45.406    0.001         44.074
## Distance_rescaled:rescaled_Time.Diff          0.751    0.910          0.334
##                                               Meles.meles         
##                                      Pr(>Dev)         Dev Pr(>Dev)
## (Intercept)                                                       
## Distance_rescaled                       0.992       0.012    0.994
## rescaled_Time.Diff                      0.144       3.238    0.314
## cosinus_Monitoring.Time.Diff            0.739       0.436    0.899
## Site                                    0.001       4.192    0.750
## Distance_rescaled:rescaled_Time.Diff    0.923       0.699    0.910
##                                      Vulpes.vulpes         
##                                                Dev Pr(>Dev)
## (Intercept)                                                
## Distance_rescaled                            0.037    0.993
## rescaled_Time.Diff                          33.757    0.001
## cosinus_Monitoring.Time.Diff                 8.616    0.036
## Site                                         3.909    0.750
## Distance_rescaled:rescaled_Time.Diff         0.155    0.928
## Arguments:
##  Test statistics calculated assuming uncorrelated response (for faster computation) 
## P-value calculated using 999 iterations via PIT-trap resampling.

Multivariate test shows that cosin monitoring time, Site, time difference and interaction between distance from settlement and time difference are statistically significant

coefp <- merge(data.table(t(coef(mva_m2)/log(2)),keep.rownames=TRUE), data.table(t(anov_m2.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","Site_Har_Amasa.coef.coef","Site_Lahav.coef","Site_Lehavim.coef","Site_Mirsham.coef","Distance_time.coef", "Intercept.p","Distance.p","Time_diff.p","Cosin_time.p","Site.p","Distance_time.p","species_abundance")

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

print(coefp)
##            SciName Intercept.coef Distance.coef Time_diff.coef Cosin_time.coef
## 1:    Canis.aureus      1.0426105   -0.49842766     -0.2547011      -0.7703213
## 2: Gazella.gazella      1.0806655   -0.03783560      1.4691821      -0.8122920
## 3:   Hyaena.hyaena     -4.1444314   -0.11357307      0.3509670       0.2731952
## 4:  Hystrix.indica     -7.5445021   -0.81949108     -0.2388161       3.4396769
## 5:  Lepus.capensis     -0.9643288    0.55167154      0.8515688       0.4104079
## 6:     Meles.meles     -4.2475336   -0.02100113      0.6439979       0.3446737
## 7:   Vulpes.vulpes      1.1132860    0.32760272      0.7923119       0.5083757
##    Site_Har_Amasa.coef.coef Site_Lahav.coef Site_Lehavim.coef Site_Mirsham.coef
## 1:               -1.6322308       0.3809060        -2.7546359        -1.2060801
## 2:               -0.9964718      -6.4625798        -3.8012093         0.0947497
## 3:                0.8451841       0.2244599        -0.7139241         0.5949948
## 4:                2.7516229       4.3285701         3.8180456         8.5896454
## 5:               -0.1058152      -4.8690602         1.7640321        -3.1111254
## 6:                1.1492627       1.0279397         1.4993780         1.5967657
## 7:                0.1112995      -0.2973630        -0.2838546        -0.3863128
##    Distance_time.coef Intercept.p Distance.p Time_diff.p Cosin_time.p Site.p
## 1:        -1.45272648          NA      0.098       0.753        0.941  0.001
## 2:        -0.53265390          NA      0.992       0.001        0.001  0.001
## 3:         0.12838062          NA      0.994       0.753        0.941  0.750
## 4:         0.60211957          NA      0.992       0.413        0.465  0.001
## 5:         0.36984801          NA      0.992       0.144        0.739  0.001
## 6:         0.44010429          NA      0.994       0.314        0.899  0.750
## 7:        -0.09700433          NA      0.993       0.001        0.036  0.750
##    Distance_time.p species_abundance
## 1:           0.002               467
## 2:           0.669               940
## 3:           0.928                22
## 4:           0.910                97
## 5:           0.923               181
## 6:           0.910                39
## 7:           0.928               708
#### 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 + Site, data = env_data)
coef(glm.Canis.aureus)
##                          (Intercept)                    Distance_rescaled 
##                            0.7226852                           -0.3454709 
##                   rescaled_Time.Diff         cosinus_Monitoring.Time.Diff 
##                           -0.1765497                           -0.5339577 
##                        SiteHar Amasa                            SiteLahav 
##                           -1.1313627                            0.2640154 
##                          SiteLehavim                          SiteMirsham 
##                           -1.9093470                           -0.8359891 
## Distance_rescaled:rescaled_Time.Diff 
##                           -1.0069294
coef(mva_m2)
##                                      Canis.aureus Gazella.gazella Hyaena.hyaena
## (Intercept)                             0.7226825      0.74906022   -2.87270092
## Distance_rescaled                      -0.3454837     -0.02622564   -0.07872285
## rescaled_Time.Diff                     -0.1765454      1.01835942    0.24327181
## cosinus_Monitoring.Time.Diff           -0.5339460     -0.56303790    0.18936451
## SiteHar Amasa                          -1.1313762     -0.69070165    0.58583696
## SiteLahav                               0.2640240     -4.47951898    0.15558375
## SiteLehavim                            -1.9093681     -2.63479750   -0.49485445
## SiteMirsham                            -0.8359910      0.06567549    0.41241896
## Distance_rescaled:rescaled_Time.Diff   -1.0069533     -0.36920755    0.08898667
##                                      Hystrix.indica Lepus.capensis Meles.meles
## (Intercept)                              -5.2294503    -0.66842180 -2.94416591
## Distance_rescaled                        -0.5680279     0.38238957 -0.01455687
## rescaled_Time.Diff                       -0.1655347     0.59026253  0.44638532
## cosinus_Monitoring.Time.Diff              2.3842023     0.28447305  0.23890958
## SiteHar Amasa                             1.9072796    -0.07334553  0.79660820
## SiteLahav                                 3.0003362    -3.37497537  0.71251350
## SiteLehavim                               2.6464676     1.22273387  1.03928967
## SiteMirsham                               5.9538885    -2.15646780  1.10679362
## Distance_rescaled:rescaled_Time.Diff      0.4173575     0.25635910  0.30505705
##                                      Vulpes.vulpes
## (Intercept)                             0.77167103
## Distance_rescaled                       0.22707690
## rescaled_Time.Diff                      0.54918876
## cosinus_Monitoring.Time.Diff            0.35237916
## SiteHar Amasa                           0.07714693
## SiteLahav                              -0.20611633
## SiteLehavim                            -0.19675301
## SiteMirsham                            -0.26777162
## Distance_rescaled:rescaled_Time.Diff   -0.06723827
print(sum(Canis.aureus))
## [1] 467
plot_model_interaction(P.anal = env_data, m = glm.Canis.aureus, 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/md_zone/", legend_position = "bottom")
## Loading required package: extrafont
## Registering fonts with R

# interact_plot(model = glm.Canis.aureus, data=env_data, pred = rescaled_Time.Diff, modx = Distance_rescaled, modx.values = "plus-minus", partial.residuals = F, jitter = c(0.2), point.size = 3, rug = F, point.shape = F, interval = T, colors = "Dark2") + scale_x_continuous(breaks=c(-1.233466888,-0.601840099,0.028922631,0.66054942,1.291312151), labels=c("June 2014", "June 2016", "June 2018", "June 2020", "June 2022"), name = "Time")

#Testing whether trends and means are different from zero

#Calculate mean and sd of distance
sd_distance <- sd(env_data$Distance_rescaled)
print(sd_distance)
## [1] 0.5278765
mean_distance <- mean(env_data$Distance_rescaled)
print(mean_distance)
## [1] -0.2131719
#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.Canis.aureus, 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.741                    0.570 0.171 Inf     0.235     0.904
##              0.315                   -0.493 0.192 Inf    -0.869    -0.118
## 
## Results are averaged over the levels of: Site 
## 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.741                    0.570 0.171 Inf   3.335  0.0017
##              0.315                   -0.493 0.192 Inf  -2.576  0.0100
## 
## Results are averaged over the levels of: Site 
## P value adjustment: fdr method for 2 tests
#Testing whether abundance is higher near or far from settlements
pairwise_distance <- emmeans(object = glm.Canis.aureus, ~Distance_rescaled*rescaled_Time.Diff, at = list(Distance_rescaled = c(small_distance,large_distance)))
test_results_distance <- test(pairs(pairwise_distance, by="rescaled_Time.Diff"), by=NULL, adjust="fdr")
print(test_results_distance)
##  contrast                                                                 
##  (Distance_rescaled-0.741048431885884) - Distance_rescaled0.31470454181471
##  rescaled_Time.Diff estimate    SE  df z.ratio p.value
##                0.34    0.727 0.246 Inf   2.952  0.0032
## 
## Results are averaged over the levels of: Site 
## Results are given on the log (not the response) scale.

Temporal trends are significantly different from zero for both large (p = 0.001) and small (p = 0.01) distances from settlements

On average over time, Jackal abundance is significantly higher near settlements (p = 0.003)

#### 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 + Site, data = env_data)
coef(glm.Gazella.gazella)
##                  (Intercept)            Distance_rescaled 
##                    0.7496189                   -0.1220151 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                    1.0639549                   -0.5311252 
##                SiteHar Amasa                    SiteLahav 
##                   -0.6811244                   -4.4244071 
##                  SiteLehavim                  SiteMirsham 
##                   -2.5844055                    0.1011102
coef(mva_m2)
##                                      Canis.aureus Gazella.gazella Hyaena.hyaena
## (Intercept)                             0.7226825      0.74906022   -2.87270092
## Distance_rescaled                      -0.3454837     -0.02622564   -0.07872285
## rescaled_Time.Diff                     -0.1765454      1.01835942    0.24327181
## cosinus_Monitoring.Time.Diff           -0.5339460     -0.56303790    0.18936451
## SiteHar Amasa                          -1.1313762     -0.69070165    0.58583696
## SiteLahav                               0.2640240     -4.47951898    0.15558375
## SiteLehavim                            -1.9093681     -2.63479750   -0.49485445
## SiteMirsham                            -0.8359910      0.06567549    0.41241896
## Distance_rescaled:rescaled_Time.Diff   -1.0069533     -0.36920755    0.08898667
##                                      Hystrix.indica Lepus.capensis Meles.meles
## (Intercept)                              -5.2294503    -0.66842180 -2.94416591
## Distance_rescaled                        -0.5680279     0.38238957 -0.01455687
## rescaled_Time.Diff                       -0.1655347     0.59026253  0.44638532
## cosinus_Monitoring.Time.Diff              2.3842023     0.28447305  0.23890958
## SiteHar Amasa                             1.9072796    -0.07334553  0.79660820
## SiteLahav                                 3.0003362    -3.37497537  0.71251350
## SiteLehavim                               2.6464676     1.22273387  1.03928967
## SiteMirsham                               5.9538885    -2.15646780  1.10679362
## Distance_rescaled:rescaled_Time.Diff      0.4173575     0.25635910  0.30505705
##                                      Vulpes.vulpes
## (Intercept)                             0.77167103
## Distance_rescaled                       0.22707690
## rescaled_Time.Diff                      0.54918876
## cosinus_Monitoring.Time.Diff            0.35237916
## SiteHar Amasa                           0.07714693
## SiteLahav                              -0.20611633
## SiteLehavim                            -0.19675301
## SiteMirsham                            -0.26777162
## Distance_rescaled:rescaled_Time.Diff   -0.06723827
print(sum(Gazella.gazella))
## [1] 940
source("functions/plot_model_effect_mammals.R")

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/md_zone/")

# effect_plot(model = glm.Gazella.gazella, data=env_data, pred = rescaled_Time.Diff, interval = T, plot.points = F, jitter = c(0.1,0), partial.residuals = F, colors = "Qual1") + ylim(0,15) + scale_x_continuous(breaks=c(-1.233466888,-0.601840099,0.028922631,0.66054942,1.291312151), labels=c("June 2014", "June 2016", "June 2018", "June 2020", "June 2022"), name = "Time")

#### 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 + Site, data = env_data)
coef(glm.Vulpes.vulpes)
##                  (Intercept)            Distance_rescaled 
##                   0.76602777                   0.21065333 
##           rescaled_Time.Diff cosinus_Monitoring.Time.Diff 
##                   0.56631374                   0.36083191 
##                SiteHar Amasa                    SiteLahav 
##                   0.07968601                  -0.20764925 
##                  SiteLehavim                  SiteMirsham 
##                  -0.19653653                  -0.25479826
coef(mva_m2)
##                                      Canis.aureus Gazella.gazella Hyaena.hyaena
## (Intercept)                             0.7226825      0.74906022   -2.87270092
## Distance_rescaled                      -0.3454837     -0.02622564   -0.07872285
## rescaled_Time.Diff                     -0.1765454      1.01835942    0.24327181
## cosinus_Monitoring.Time.Diff           -0.5339460     -0.56303790    0.18936451
## SiteHar Amasa                          -1.1313762     -0.69070165    0.58583696
## SiteLahav                               0.2640240     -4.47951898    0.15558375
## SiteLehavim                            -1.9093681     -2.63479750   -0.49485445
## SiteMirsham                            -0.8359910      0.06567549    0.41241896
## Distance_rescaled:rescaled_Time.Diff   -1.0069533     -0.36920755    0.08898667
##                                      Hystrix.indica Lepus.capensis Meles.meles
## (Intercept)                              -5.2294503    -0.66842180 -2.94416591
## Distance_rescaled                        -0.5680279     0.38238957 -0.01455687
## rescaled_Time.Diff                       -0.1655347     0.59026253  0.44638532
## cosinus_Monitoring.Time.Diff              2.3842023     0.28447305  0.23890958
## SiteHar Amasa                             1.9072796    -0.07334553  0.79660820
## SiteLahav                                 3.0003362    -3.37497537  0.71251350
## SiteLehavim                               2.6464676     1.22273387  1.03928967
## SiteMirsham                               5.9538885    -2.15646780  1.10679362
## Distance_rescaled:rescaled_Time.Diff      0.4173575     0.25635910  0.30505705
##                                      Vulpes.vulpes
## (Intercept)                             0.77167103
## Distance_rescaled                       0.22707690
## rescaled_Time.Diff                      0.54918876
## cosinus_Monitoring.Time.Diff            0.35237916
## SiteHar Amasa                           0.07714693
## SiteLahav                              -0.20611633
## SiteLehavim                            -0.19675301
## SiteMirsham                            -0.26777162
## Distance_rescaled:rescaled_Time.Diff   -0.06723827
print(sum(Vulpes.vulpes))
## [1] 708
plot_model_effect(P.anal = env_data, m = glm.Vulpes.vulpes, 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/md_zone/")

# effect_plot(model = glm.Vulpes.vulpes, data=env_data, pred = rescaled_Time.Diff, interval = T, plot.points = F, jitter = c(0.1,0), partial.residuals = F, colors = "Qual1") + ylim(0,10) + scale_x_continuous(breaks=c(-1.233466888,-0.601840099,0.028922631,0.66054942,1.291312151), labels=c("June 2014", "June 2016", "June 2018", "June 2020", "June 2022"), name = "Time")

n = 281 (total number of cameras)

total abundance = 2454 (7 species), total abundance without rare species is the same (all rare species had zero observations)

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