# title: "Ae_albopictus_Abnd_GAP"
# Date: 12/19/2023
# Latest: 01/02/2024
# output: html_notebook
— Package Library
setwd("C:/Users/hullt/OneDrive - Saint Louis University/Dissertation/Chapter 4 - Area of vegetation vs. volume of vegetation/R_WD/Ae_albopictus")
library(broom)
library(dplyr)
library(forcats)
library(foreign)
library(gratia)
library(mgcv)
library(readr)
— Import Ae albopictus csv
Aa_Abnd <- read_csv("Ae_albopictus_AbndRslts.csv",
col_types = cols(BCH_ID = col_character(),
VOL = col_integer(), Smpls_ALL = col_integer(),
SmplsDtctd_ALL = col_integer(), TtlAbnd_ALL = col_integer(),
Smpls_2020 = col_integer(), SmplsDtctd_2020 = col_integer(),
TtlAbnd_2020 = col_integer(), Smpls_2021 = col_integer(),
SmplsDtctd_2021 = col_integer(),
TtlAbnd_2021 = col_integer()))
Aa_Abnd.41 <- Aa_Abnd[-c(8,25),]
attach(Aa_Abnd.41)
— GAP model for 2020 & 2021; Predictor Variable: Total Species Abundance
AaArea.TA_ALL <- gam(TtlAbnd_ALL~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.TA_ALL)
Family: Negative Binomial(1.26)
Link function: log
Formula:
TtlAbnd_ALL ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.7632 0.1452 19.03 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 4.047 4.971 15.59 0.00769 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.241 Deviance explained = 33.2%
-REML = 161.8 Scale est. = 1 n = 41
draw(AaArea.TA_ALL)
appraise(AaArea.TA_ALL)
AaVOL.TA_ALL <- gam(TtlAbnd_ALL~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.TA_ALL)
Family: Negative Binomial(0.895)
Link function: log
Formula:
TtlAbnd_ALL ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.9661 0.1689 17.57 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.147 0.702
R-sq.(adj) = -0.021 Deviance explained = 0.379%
-REML = 165.39 Scale est. = 1 n = 41
draw(AaVOL.TA_ALL)
appraise(AaVOL.TA_ALL)
ANOV.TA_ALL <- anova(AaArea.TA_ALL, AaVOL.TA_ALL, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.TA_ALL)
Analysis of Deviance Table
Model 1: TtlAbnd_ALL ~ s(AREA)
Model 2: TtlAbnd_ALL ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 34.473 309.28
2 39.000 327.25 -4.5269 -17.966 0.002015 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
— GAP model for 2020 & 2021; Predictor Variable: Average Sample Abundance
AaArea.AA_ALL <- gam(AvgAbnd_ALL~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.AA_ALL)
Family: Negative Binomial(150475.219)
Link function: log
Formula:
AvgAbnd_ALL ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.8152 0.2365 -3.447 0.000568 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 2.977 3.708 3.958 0.284
R-sq.(adj) = 0.203 Deviance explained = 16.5%
-REML = 44.234 Scale est. = 1 n = 41
draw(AaArea.AA_ALL)
appraise(AaArea.AA_ALL)
AaVOL.AA_ALL <- gam(AvgAbnd_ALL~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.AA_ALL)
Family: Negative Binomial(312028.273)
Link function: log
Formula:
AvgAbnd_ALL ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.7476 0.2272 -3.29 0.001 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.116 0.733
R-sq.(adj) = -0.0209 Deviance explained = 0.272%
-REML = 44.691 Scale est. = 1 n = 41
draw(AaVOL.AA_ALL)
appraise(AaVOL.AA_ALL)
ANOV.AA_ALL <- anova(AaArea.AA_ALL, AaVOL.AA_ALL, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.AA_ALL)
Analysis of Deviance Table
Model 1: AvgAbnd_ALL ~ s(AREA)
Model 2: AvgAbnd_ALL ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 35.56 61.399
2 39.00 67.916 -3.4402 -6.5164 0.119
— GAP model for 2020; Predictor Variable: Total species Abundance
AaArea.TA_20 <- gam(TtlAbnd_2020~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.TA_20)
Family: Negative Binomial(0.756)
Link function: log
Formula:
TtlAbnd_2020 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.06799 0.24594 0.276 0.782
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 1 1 3.793 0.0515 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.0327 Deviance explained = 10.1%
-REML = 60.964 Scale est. = 1 n = 41
draw(AaArea.TA_20)
appraise(AaArea.TA_20)
AaVOL.TA_20 <- gam(TtlAbnd_2020~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.TA_20)
Family: Negative Binomial(0.655)
Link function: log
Formula:
TtlAbnd_2020 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.1661 0.2427 0.684 0.494
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.892 0.345
R-sq.(adj) = -0.00561 Deviance explained = 2.55%
-REML = 62.602 Scale est. = 1 n = 41
draw(AaVOL.TA_20)
appraise(AaVOL.TA_20)
ANOV.TA_20 <- anova(AaArea.TA_20, AaVOL.TA_20, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.TA_20)
Analysis of Deviance Table
Model 1: TtlAbnd_2020 ~ s(AREA)
Model 2: TtlAbnd_2020 ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 39 120.35
2 39 123.48 0.00019821 -3.1375
— GAP model for 2020_; Predictor Variable:Average Sample Abundance
AaArea.AA_20 <- gam(AvgAbnd_2020~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.AA_20)
Family: Negative Binomial(416994.672)
Link function: log
Formula:
AvgAbnd_2020 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.6366 0.6419 -4.108 4e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 1 1 0.428 0.513
R-sq.(adj) = 0.0328 Deviance explained = 3.66%
-REML = 14.154 Scale est. = 1 n = 41
draw(AaArea.AA_20)
appraise(AaArea.AA_20)
AaVOL.AA_20 <- gam(AvgAbnd_2020~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.AA_20)
Family: Negative Binomial(422192.885)
Link function: log
Formula:
AvgAbnd_2020 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.5459 0.5743 -4.433 9.29e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.136 0.712
R-sq.(adj) = -0.00514 Deviance explained = 1.09%
-REML = 14.431 Scale est. = 1 n = 41
draw(AaVOL.AA_20)
appraise(AaVOL.AA_20)
ANOV.AA_20 <- anova(AaArea.AA_20, AaVOL.AA_20, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.AA_20)
Analysis of Deviance Table
Model 1: AvgAbnd_2020 ~ s(AREA)
Model 2: AvgAbnd_2020 ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 39 20.252
2 39 20.682 -1.6018e-06 -0.4301 9.32e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
— GAP model for 2021; Predictor Variable: Total Species Abundance
AaArea.TA_21 <- gam(TtlAbnd_2021~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.TA_21)
Family: Negative Binomial(0.944)
Link function: log
Formula:
TtlAbnd_2021 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.6682 0.1666 16.02 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 3.876 4.77 13.24 0.0173 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.247 Deviance explained = 29%
-REML = 158.54 Scale est. = 1 n = 41
draw(AaArea.TA_21)
appraise(AaArea.TA_21)
AaVOL.TA_21 <- gam(TtlAbnd_2021~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.TA_21)
Family: Negative Binomial(0.69)
Link function: log
Formula:
TtlAbnd_2021 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.9002 0.1916 15.14 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.171 0.679
R-sq.(adj) = -0.0194 Deviance explained = 0.431%
-REML = 161.41 Scale est. = 1 n = 41
draw(AaVOL.TA_21)
appraise(AaVOL.TA_21)
ANOV.TA_21 <- anova(AaArea.TA_21, AaVOL.TA_21, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.TA_21)
Analysis of Deviance Table
Model 1: TtlAbnd_2021 ~ s(AREA)
Model 2: TtlAbnd_2021 ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 34.612 303.99
2 38.999 319.79 -4.3876 -15.798 0.004601 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
— GAP model for 2021_; Predictor Variable:Average Sample Abundance
AaArea.AA_21 <- gam(AvgAbnd_2021~s(AREA),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaArea.AA_21)
Family: Negative Binomial(55549.654)
Link function: log
Formula:
AvgAbnd_2021 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.4967 0.2062 -2.409 0.016 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 3.746 4.619 11.15 0.0399 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.266 Deviance explained = 27.1%
-REML = 51.849 Scale est. = 1 n = 41
draw(AaArea.AA_21)
appraise(AaArea.AA_21)
AaVOL.AA_21 <- gam(AvgAbnd_2021~s(VOL),data = Aa_Abnd.41, method = "REML", family = nb())
summary(AaVOL.AA_21)
Family: Negative Binomial(6.402)
Link function: log
Formula:
AvgAbnd_2021 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.3582 0.1970 -1.818 0.0691 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 1 1 0.229 0.632
R-sq.(adj) = -0.0193 Deviance explained = 0.465%
-REML = 54.14 Scale est. = 1 n = 41
draw(AaVOL.AA_21)
appraise(AaVOL.AA_21)
ANOV.AA_21 <- anova(AaArea.AA_21, AaVOL.AA_21, test = c("Chisq", "F", "Cp"))
Warning: 'length(x) = 3 > 1' in coercion to 'logical(1)'
print(ANOV.AA_21)
Analysis of Deviance Table
Model 1: AvgAbnd_2021 ~ s(AREA)
Model 2: AvgAbnd_2021 ~ s(VOL)
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
1 34.578 76.011
2 39.000 89.476 -4.4218 -13.464 0.01283 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1