Attack rate is measured as the proportion of 20 clay caterpillars on 10 trees that were attacked at a site on a unique date. There are 5 drainages, 4 sites within each, and either 3 to 4 sampling dates, resulting in 76 attack rates.
Bird diversity and abundance acquired from eBird along the same elevational gradient during the same time period of clay caterpillar data collection (Aug 2020), resulting in a total of 80 checklists, and 44 data points when averaged to the location due to uneven amounts of data per location. Diversity and abundance data account for sampling effort by using the residuals of each with time (duration length of each checklist).
attack_Anova <- lmer(Propattack ~ elevation_m + pc1 + (1 | Site),
data = claycat) #Proportion attack rate at a unique site & date with elevation, aridity, and site as a random factor
summary(attack_Anova)## Linear mixed model fit by REML ['lmerMod']
## Formula: Propattack ~ elevation_m + pc1 + (1 | Site)
## Data: claycat
##
## REML criterion at convergence: -33.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9694 -0.7071 -0.1543 0.6941 2.8909
##
## Random effects:
## Groups Name Variance Std.Dev.
## Site (Intercept) 0.00567 0.0753
## Residual 0.02300 0.1517
## Number of obs: 76, groups: Site, 20
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -1.7292108 0.6548022 -2.641
## elevation_m 0.0006854 0.0002374 2.888
## pc1 0.0796206 0.0311676 2.555
##
## Correlation of Fixed Effects:
## (Intr) elvtn_
## elevation_m -0.999
## pc1 -0.894 0.895
Anova(attack_Anova)## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: Propattack
## Chisq Df Pr(>Chisq)
## elevation_m 8.3396 1 0.003879 **
## pc1 6.5260 1 0.010631 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
eBird_Anova1 <- lm(div_residual_ave ~ elevation + pc1, data = ebird)
# ebird checklists: bird diversity accounting for sampling
# effort (time) averaged per location (elevation) with
# elevation and aridity
summary(eBird_Anova1)##
## Call:
## lm(formula = div_residual_ave ~ elevation + pc1, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.30964 -0.34414 -0.07358 0.52254 1.04957
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.2624989 1.6608168 0.760 0.452
## elevation -0.0005005 0.0006006 -0.833 0.409
## pc1 -0.0603714 0.0689849 -0.875 0.387
##
## Residual standard error: 0.5409 on 41 degrees of freedom
## Multiple R-squared: 0.02032, Adjusted R-squared: -0.02747
## F-statistic: 0.4252 on 2 and 41 DF, p-value: 0.6565
eBird_Anova1 <- lm(abun_residual_ave ~ elevation + pc1, data = ebird)
# ebird checklists: bird abundance accounting for sampling
# effort (time) averaged per location (elevation) with
# elevation and aridity
summary(eBird_Anova1)##
## Call:
## lm(formula = abun_residual_ave ~ elevation + pc1, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -66.208 -15.428 -2.049 10.106 131.555
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 193.86069 94.89392 2.043 0.0475 *
## elevation -0.07244 0.03431 -2.111 0.0409 *
## pc1 -3.23859 3.94158 -0.822 0.4160
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 30.9 on 41 degrees of freedom
## Multiple R-squared: 0.1181, Adjusted R-squared: 0.07512
## F-statistic: 2.746 on 2 and 41 DF, p-value: 0.07598
attack_model_A <- lm(Propattack ~ elevation_m, data = claycat) #attack rate with elevation
claycat$ele_residuals <- resid(attack_model_A) #Getting the residuals that account for elevation
attack_model_A <- lm(ele_residuals ~ pc1, data = claycat) #model the attack rate/elevation residuals with aridity
summary(attack_model_A)##
## Call:
## lm(formula = ele_residuals ~ pc1, data = claycat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.17238 -0.11619 -0.05182 0.08422 0.61020
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0009708 0.0202163 0.048 0.962
## pc1 0.0160787 0.0115115 1.397 0.167
##
## Residual standard error: 0.1761 on 74 degrees of freedom
## Multiple R-squared: 0.02569, Adjusted R-squared: 0.01252
## F-statistic: 1.951 on 1 and 74 DF, p-value: 0.1667
Anova(attack_model_A)## Anova Table (Type II tests)
##
## Response: ele_residuals
## Sum Sq Df F value Pr(>F)
## pc1 0.06053 1 1.9509 0.1667
## Residuals 2.29580 74
attack_model_B <- lm(Propattack ~ pc1, data = claycat) #attack rate with aridity
claycat$pc1_residuals <- resid(attack_model_B) #Getting the residuals that account for aridity
attack_model_B <- lm(pc1_residuals ~ elevation_m, data = claycat)
# model the attack rate/aridity residuals with elevation
summary(attack_model_B)##
## Call:
## lm(formula = pc1_residuals ~ elevation_m, data = claycat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.19623 -0.13203 -0.06794 0.08555 0.61381
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.860e-01 2.501e-01 -1.543 0.127
## elevation_m 1.395e-04 9.008e-05 1.548 0.126
##
## Residual standard error: 0.1786 on 74 degrees of freedom
## Multiple R-squared: 0.03138, Adjusted R-squared: 0.01829
## F-statistic: 2.397 on 1 and 74 DF, p-value: 0.1258
Anova(attack_model_B)## Anova Table (Type II tests)
##
## Response: pc1_residuals
## Sum Sq Df F value Pr(>F)
## elevation_m 0.0765 1 2.3974 0.1258
## Residuals 2.3614 74
## Warning in gzfile(file, mode): cannot open compressed file 'C:/Users/lydia/
## AppData/Local/Temp/RtmpqwFoWJ\file751c1724dd0', probable reason 'No such file or
## directory'
## Joining, by = "Site"
## Joining, by = "Site"
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
Using color and size to see the overlap
## Joining, by = "Site"
## `geom_smooth()` using formula 'y ~ x'
Using transparant instead of color to see overlap in points
ggplot(data = claycat_ave, aes(x = elevation_m, y = pc1, size = ave.propattack)) +
geom_point(alpha = 0.3) + labs(size = "Attack rate") + geom_smooth(colour = "black",
size = 1.5, show.legend = F, method = "lm", se = FALSE) +
theme(text = element_text(size = 15)) + labs(x = "Elevation (meters)",
y = "Aridity") + theme(axis.text.y = element_text(angle = 90)) +
theme(axis.line.y = element_line(color = "black"), axis.line.x = element_line(color = "black")) +
theme(panel.background = element_rect(fill = "white", colour = "white")) +
theme(legend.key = element_blank())## `geom_smooth()` using formula 'y ~ x'
Regular just black with size
ggplot(data = claycat_ave, aes(x = elevation_m, y = pc1, size = ave.propattack)) +
geom_point() + labs(size = "Attack rate") + geom_smooth(colour = "black",
size = 1.5, show.legend = F, method = "lm", se = FALSE) +
theme(text = element_text(size = 15)) + labs(x = "Elevation (meters)",
y = "Aridity") + theme(axis.text.y = element_text(angle = 90)) +
theme(axis.line.y = element_line(color = "black"), axis.line.x = element_line(color = "black")) +
theme(panel.background = element_rect(fill = "white", colour = "white")) +
theme(legend.key = element_blank())## `geom_smooth()` using formula 'y ~ x'
eBird_Model_A <- lm(div_residual_ave ~ elevation, data = ebird)
# bird diversity (accounting for sampling effort) with
# elevation
ebird$ele_div_residuals <- resid(eBird_Model_A) #Getting the residuals that account for elevation
eBird_Model_A <- lm(ele_div_residuals ~ pc1, data = ebird) #model the diversity/elevation residuals with aridity
summary(eBird_Model_A)##
## Call:
## lm(formula = ele_div_residuals ~ pc1, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.29855 -0.32111 -0.09451 0.47136 1.09896
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.006793 0.081716 -0.083 0.934
## pc1 -0.028853 0.047349 -0.609 0.546
##
## Residual standard error: 0.537 on 42 degrees of freedom
## Multiple R-squared: 0.008764, Adjusted R-squared: -0.01484
## F-statistic: 0.3713 on 1 and 42 DF, p-value: 0.5456
eBird_Model_B <- lm(abun_residual_ave ~ elevation, data = ebird)
# bird abundance (accounting for sampling effort) with
# elevation
ebird$ele_abun_residuals <- resid(eBird_Model_B) #Getting the residuals that account for elevation
eBird_Model_B <- lm(ele_abun_residuals ~ pc1, data = ebird) #model the abundance/elevation residuals with aridityeBird_Model_C <- lm(div_residual_ave ~ pc1, data = ebird)
# bird diversity (accounting for sampling effort) with
# aridity
ebird$pc1_div_residuals <- resid(eBird_Model_C) #Getting the residuals that account for aridity
eBird_Model_C <- lm(pc1_div_residuals ~ elevation, data = ebird) #model the diversity/aridity residuals with elevation
summary(eBird_Model_C)##
## Call:
## lm(formula = pc1_div_residuals ~ elevation, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.3082 -0.3239 -0.0983 0.4889 1.1629
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.6654024 1.1489253 0.579 0.566
## elevation -0.0002392 0.0004120 -0.581 0.565
##
## Residual standard error: 0.5367 on 42 degrees of freedom
## Multiple R-squared: 0.007962, Adjusted R-squared: -0.01566
## F-statistic: 0.3371 on 1 and 42 DF, p-value: 0.5646
eBird_Model_D <- lm(abun_residual_ave ~ pc1, data = ebird)
# bird abundance (accounting for sampling effort) with
# aridity
ebird$pc1_abun_residuals <- resid(eBird_Model_D) #Getting the residuals that account for aridity
eBird_Model_D <- lm(pc1_abun_residuals ~ elevation, data = ebird) #model the abundance/aridity residuals with elevation
summary(eBird_Model_D)##
## Call:
## lm(formula = pc1_abun_residuals ~ elevation, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -66.42 -12.97 -3.25 10.75 132.53
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 96.30085 67.18644 1.433 0.159
## elevation -0.03462 0.02409 -1.437 0.158
##
## Residual standard error: 31.39 on 42 degrees of freedom
## Multiple R-squared: 0.04686, Adjusted R-squared: 0.02416
## F-statistic: 2.065 on 1 and 42 DF, p-value: 0.1582
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'