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. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Propattack ~ elevation_m + pc1 + (1 | Site)
## Data: claycat
##
## REML criterion at convergence: -32.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9145 -0.6684 -0.1599 0.6362 2.7063
##
## Random effects:
## Groups Name Variance Std.Dev.
## Site (Intercept) 0.006981 0.08355
## Residual 0.022949 0.15149
## Number of obs: 76, groups: Site, 20
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -1.7358828 0.7902399 18.1278108 -2.197 0.0413 *
## elevation_m 0.0006881 0.0002866 18.0570603 2.401 0.0274 *
## pc1 0.0759048 0.0367418 17.3265565 2.066 0.0541 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) elvtn_
## elevation_m -0.999
## pc1 -0.921 0.921
anova(attack_Anova)## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## elevation_m 0.132255 0.132255 1 18.057 5.7630 0.02735 *
## pc1 0.097945 0.097945 1 17.327 4.2679 0.05413 .
## ---
## 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.29885 -0.32448 -0.08318 0.51153 1.01352
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.5133359 1.6839441 0.899 0.374
## elevation -0.0005932 0.0006100 -0.973 0.337
## pc1 -0.0621350 0.0589807 -1.053 0.298
##
## Residual standard error: 0.5386 on 41 degrees of freedom
## Multiple R-squared: 0.02832, Adjusted R-squared: -0.01907
## F-statistic: 0.5976 on 2 and 41 DF, p-value: 0.5549
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
## -64.997 -15.646 -2.435 10.194 131.165
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 198.67415 96.53002 2.058 0.0460 *
## elevation -0.07425 0.03497 -2.124 0.0398 *
## pc1 -2.91786 3.38099 -0.863 0.3931
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 30.88 on 41 degrees of freedom
## Multiple R-squared: 0.1196, Adjusted R-squared: 0.07666
## F-statistic: 2.785 on 2 and 41 DF, p-value: 0.07342
attack_model_A <- lmer(Propattack ~ elevation_m + (1 | Site),
data = claycat) #attack rate with elevation
claycat$ele_residuals <- resid(attack_model_A) #Getting the residuals that account for elevation
attack_model_A <- lmer(ele_residuals ~ pc1 + (1 | Site), data = claycat) #model the attack rate/elevation residuals with aridity## boundary (singular) fit: see help('isSingular')
summary(attack_model_A)## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ele_residuals ~ pc1 + (1 | Site)
## Data: claycat
##
## REML criterion at convergence: -71.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.0847 -0.7774 -0.2240 0.5773 3.1212
##
## Random effects:
## Groups Name Variance Std.Dev.
## Site (Intercept) 0.00000 0.0000
## Residual 0.01947 0.1395
## Number of obs: 76, groups: Site, 20
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 3.405e-04 1.602e-02 7.400e+01 0.021 0.983
## pc1 4.423e-03 8.918e-03 7.400e+01 0.496 0.621
##
## Correlation of Fixed Effects:
## (Intr)
## pc1 0.043
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
anova(attack_model_A)## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## pc1 0.004788 0.004788 1 74 0.246 0.6214
attack_model_B <- lmer(Propattack ~ pc1 + (1 | Site), data = claycat) #attack rate with aridity
claycat$pc1_residuals <- resid(attack_model_B) #Getting the residuals that account for aridity
attack_model_B <- lmer(pc1_residuals ~ elevation_m + (1 | Site),
data = claycat)## boundary (singular) fit: see help('isSingular')
# model the attack rate/aridity residuals with elevation
summary(attack_model_B)## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pc1_residuals ~ elevation_m + (1 | Site)
## Data: claycat
##
## REML criterion at convergence: -62.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1776 -0.7704 -0.2233 0.6118 3.0949
##
## Random effects:
## Groups Name Variance Std.Dev.
## Site (Intercept) 0.00000 0.000
## Residual 0.01932 0.139
## Number of obs: 76, groups: Site, 20
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -1.063e-01 1.946e-01 7.400e+01 -0.546 0.587
## elevation_m 3.842e-05 7.009e-05 7.400e+01 0.548 0.585
##
## Correlation of Fixed Effects:
## (Intr)
## elevation_m -0.997
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
anova(attack_model_B)## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## elevation_m 0.0058046 0.0058046 1 74 0.3005 0.5852
## 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
Using transparant instead of color to see overlap in points
## Joining, by = "Site"
## `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.29160 -0.32490 -0.08708 0.46757 1.07826
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.009747 0.081949 -0.119 0.906
## pc1 -0.028550 0.039790 -0.718 0.477
##
## Residual standard error: 0.5361 on 42 degrees of freedom
## Multiple R-squared: 0.01211, Adjusted R-squared: -0.01141
## F-statistic: 0.5149 on 1 and 42 DF, p-value: 0.477
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 aridity
summary(eBird_Model_B)##
## Call:
## lm(formula = ele_abun_residuals ~ pc1, data = ebird)
##
## Residuals:
## Min 1Q Median 3Q Max
## -63.568 -14.151 -3.502 9.853 131.938
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.4577 4.6865 -0.098 0.923
## pc1 -1.3407 2.2755 -0.589 0.559
##
## Residual standard error: 30.66 on 42 degrees of freedom
## Multiple R-squared: 0.008198, Adjusted R-squared: -0.01542
## F-statistic: 0.3472 on 1 and 42 DF, p-value: 0.5589
eBird_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.3048 -0.3167 -0.1013 0.4867 1.1498
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.7581991 1.1462765 0.661 0.512
## elevation -0.0002726 0.0004111 -0.663 0.511
##
## Residual standard error: 0.5355 on 42 degrees of freedom
## Multiple R-squared: 0.01036, Adjusted R-squared: -0.0132
## F-statistic: 0.4397 on 1 and 42 DF, p-value: 0.5109
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
## -67.400 -12.804 -2.388 10.937 132.816
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 94.90390 67.21610 1.412 0.165
## elevation -0.03412 0.02410 -1.415 0.164
##
## Residual standard error: 31.4 on 42 degrees of freedom
## Multiple R-squared: 0.04553, Adjusted R-squared: 0.0228
## F-statistic: 2.003 on 1 and 42 DF, p-value: 0.1643
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'
## `geom_smooth()` using formula 'y ~ x'