# title: "Cx_pipiens_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/Cx_pipiens")
library(broom)
library(dplyr)
library(forcats)
library(foreign)
library(gratia)
library(mgcv)
library(readr)
— Import Cx pipiens csv
— GAP model for 2020 & 2021; Predictor Variable: Total Species Abundance
CpArea.TA_ALL <- gam(TtlAbnd_ALL~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.TA_ALL)
Family: Negative Binomial(2.713)
Link function: log
Formula:
TtlAbnd_ALL ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.48818 0.09626 46.63 <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) 1 1 0.16 0.69
R-sq.(adj) = -0.0226 Deviance explained = 0.383%
-REML = 218.97 Scale est. = 1 n = 41
draw(CpArea.TA_ALL)
appraise(CpArea.TA_ALL)
CpVOL.TA_ALL <- gam(TtlAbnd_ALL~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.TA_ALL)
Family: Negative Binomial(2.938)
Link function: log
Formula:
TtlAbnd_ALL ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.46853 0.09268 48.22 <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) 2.066 2.53 5.012 0.137
R-sq.(adj) = 0.00143 Deviance explained = 10.7%
-REML = 218 Scale est. = 1 n = 41
draw(CpVOL.TA_ALL)
appraise(CpVOL.TA_ALL)
ANOV.TA_ALL <- anova(CpArea.TA_ALL, CpVOL.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 39.000 432.25
2 37.006 427.61 1.9932 4.6445 0.09748 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
— GAP model for 2020 & 2021; Predictor Variable: Average Sample Abundance
CpArea.AA_ALL <- gam(AvgAbnd_ALL~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.AA_ALL)
Family: Negative Binomial(34.08)
Link function: log
Formula:
AvgAbnd_ALL ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.7746 0.1094 7.081 1.43e-12 ***
---
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.12 0.729
R-sq.(adj) = -0.0226 Deviance explained = 0.348%
-REML = 73.122 Scale est. = 1 n = 41
draw(CpArea.AA_ALL)
appraise(CpArea.AA_ALL)
CpVOL.AA_ALL <- gam(AvgAbnd_ALL~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.AA_ALL)
Family: Negative Binomial(48.217)
Link function: log
Formula:
AvgAbnd_ALL ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.7684 0.1090 7.052 1.77e-12 ***
---
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.682 2.068 1.369 0.542
R-sq.(adj) = 0.00113 Deviance explained = 5.95%
-REML = 72.731 Scale est. = 1 n = 41
draw(CpVOL.AA_ALL)
appraise(CpVOL.AA_ALL)
ANOV.AA_ALL <- anova(CpArea.AA_ALL, CpVOL.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 39.000 138.50
2 37.546 136.47 1.4535 2.0258 0.2464
— GAP model for 2020; Predictor Variable: Total species Abundance
CpArea.TA_20 <- gam(TtlAbnd_2020~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.TA_20)
Family: Negative Binomial(2.611)
Link function: log
Formula:
TtlAbnd_2020 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.4563 0.0981 45.42 <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) 1 1.001 0.127 0.722
R-sq.(adj) = -0.0232 Deviance explained = 0.31%
-REML = 218.19 Scale est. = 1 n = 41
draw(CpArea.TA_20)
appraise(CpArea.TA_20)
CpVOL.TA_20 <- gam(TtlAbnd_2020~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.TA_20)
Family: Negative Binomial(2.744)
Link function: log
Formula:
TtlAbnd_2020 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.4430 0.0958 46.38 <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.724 2.115 3.154 0.227
R-sq.(adj) = -0.0112 Deviance explained = 7.02%
-REML = 217.48 Scale est. = 1 n = 41
draw(CpVOL.TA_20)
appraise(CpVOL.TA_20)
ANOV.TA_20 <- anova(CpArea.TA_20, CpVOL.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 38.999 430.74
2 37.494 427.78 1.5049 2.9618 0.1515
— GAP model for 2020_; Predictor Variable:Average Sample Abundance
CpArea.AA_20 <- gam(AvgAbnd_2020~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.AA_20)
Family: Negative Binomial(4.073)
Link function: log
Formula:
AvgAbnd_2020 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.7482 0.1012 17.28 <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) 1 1 0.12 0.73
R-sq.(adj) = -0.0232 Deviance explained = 0.321%
-REML = 108.99 Scale est. = 1 n = 41
draw(CpArea.AA_20)
appraise(CpArea.AA_20)
CpVOL.AA_20 <- gam(AvgAbnd_2020~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.AA_20)
Family: Negative Binomial(4.28)
Link function: log
Formula:
AvgAbnd_2020 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.7401 0.1001 17.39 <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.536 1.877 1.887 0.448
R-sq.(adj) = -0.0105 Deviance explained = 5.33%
-REML = 108.46 Scale est. = 1 n = 41
draw(CpVOL.AA_20)
appraise(CpVOL.AA_20)
ANOV.AA_20 <- anova(CpArea.AA_20, CpVOL.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.000 212.50
2 37.783 210.52 1.2163 1.9847 0.2025
— GAP model for 2021; Predictor Variable: Total Species Abundance
CpArea.TA_21 <- gam(TtlAbnd_2021~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.TA_21)
Family: Negative Binomial(0.029)
Link function: log
Formula:
TtlAbnd_2021 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.0089 0.9269 1.089 0.276
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(AREA) 1 1 0.131 0.718
R-sq.(adj) = -0.029 Deviance explained = 0.476%
-REML = 36.398 Scale est. = 1 n = 41
draw(CpArea.TA_21)
appraise(CpArea.TA_21)
CpVOL.TA_21 <- gam(TtlAbnd_2021~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.TA_21)
Family: Negative Binomial(0.056)
Link function: log
Formula:
TtlAbnd_2021 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.9494 2.3282 -0.408 0.683
Approximate significance of smooth terms:
edf Ref.df Chi.sq p-value
s(VOL) 3.043 3.809 5.863 0.207
R-sq.(adj) = -0.0567 Deviance explained = 37%
-REML = 35.249 Scale est. = 1 n = 41
draw(CpVOL.TA_21)
appraise(CpVOL.TA_21)
ANOV.TA_21 <- anova(CpArea.TA_21, CpVOL.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 39.000 76.963
2 35.922 70.807 3.0777 6.1559 0.1099
— GAP model for 2021_; Predictor Variable:Average Sample Abundance
CpArea.AA_21 <- gam(AvgAbnd_2021~s(AREA),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpArea.AA_21)
Family: Negative Binomial(0.178)
Link function: log
Formula:
AvgAbnd_2021 ~ s(AREA)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.3703 0.6455 -3.672 0.000241 ***
---
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.717 2.147 0.788 0.75
R-sq.(adj) = -0.0206 Deviance explained = 9.04%
-REML = 13.587 Scale est. = 1 n = 41
draw(CpArea.AA_21)
appraise(CpArea.AA_21)
CpVOL.AA_21 <- gam(AvgAbnd_2021~s(VOL),data = Cp_Abnd.41, method = "REML", family = nb())
summary(CpVOL.AA_21)
Family: Negative Binomial(0.238)
Link function: log
Formula:
AvgAbnd_2021 ~ s(VOL)
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -3.614 1.789 -2.02 0.0434 *
---
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) 2.662 3.392 3.343 0.431
R-sq.(adj) = 0.0287 Deviance explained = 39.8%
-REML = 11.604 Scale est. = 1 n = 41
draw(CpVOL.AA_21)
appraise(CpVOL.AA_21)
ANOV.AA_21 <- anova(CpArea.AA_21, CpVOL.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 37.423 26.524
2 36.032 21.817 1.3908 4.7065 0.05108 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1