Predation rate of insectivorous birds across an elevational gradient

This file contains the statistical models, analyses, and visualizations.

9/13/22 Updated analyses

Proportion models with reciprocal climate & elevation residuals (& differing proportions- averaged across dates or not)

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1576  0.1577  0.1585  0.1596  0.1616  0.1641
claycatmodelA <- lm(pc1_residuals ~  elevation_m, data = ave.prop.attack) #model the residuals with elevation
summary(claycatmodelA)
## 
## Call:
## lm(formula = pc1_residuals ~ elevation_m, data = ave.prop.attack)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14759 -0.06388 -0.01709  0.03531  0.41475 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.00196    0.02745   0.071    0.944
## elevation_m  0.03013    0.02700   1.116    0.279
## 
## Residual standard error: 0.1225 on 18 degrees of freedom
## Multiple R-squared:  0.06472,    Adjusted R-squared:  0.01276 
## F-statistic: 1.245 on 1 and 18 DF,  p-value: 0.2791
## `geom_smooth()` using formula 'y ~ x'

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1174  0.1339  0.1516  0.1596  0.1889  0.2163
claycatmodelA <- lm(ele_residuals ~  pc1, data = ave.prop.attack) #model the residuals with elevation
summary(claycatmodelA)
## 
## Call:
## lm(formula = ele_residuals ~ pc1, data = ave.prop.attack)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.13985 -0.05216 -0.03010  0.02246  0.41130 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.0009368  0.0265377  -0.035    0.972
## pc1          0.0272494  0.0269111   1.013    0.325
## 
## Residual standard error: 0.1186 on 18 degrees of freedom
## Multiple R-squared:  0.05389,    Adjusted R-squared:  0.00133 
## F-statistic: 1.025 on 1 and 18 DF,  p-value: 0.3247
## `geom_smooth()` using formula 'y ~ x'

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.1160  0.1331  0.1555  0.1612  0.1946  0.2170
## Joining, by = "elevation_m"
claycatmodelA <- lm(ele_residual_ave ~  pc1, data = prop.attack) #model the residuals with elevation
summary(claycatmodelA)
## 
## Call:
## lm(formula = ele_residual_ave ~ pc1, data = prop.attack)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14053 -0.05205 -0.03142  0.02172  0.41020 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept) 4.823e-18  1.336e-02   0.000   1.0000  
## pc1         2.824e-02  1.337e-02   2.112   0.0381 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1165 on 74 degrees of freedom
## Multiple R-squared:  0.05685,    Adjusted R-squared:  0.04411 
## F-statistic: 4.461 on 1 and 74 DF,  p-value: 0.03806
## `geom_smooth()` using formula 'y ~ x'

claycatmodelA <- lm(pc1_residual_ave ~  elevation_m, data = prop.attack) #model the residuals with elevation
summary(claycatmodelA)
## 
## Call:
## lm(formula = pc1_residual_ave ~ elevation_m, data = prop.attack)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14737 -0.07021 -0.02473  0.03567  0.41381 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept) 8.971e-18  1.379e-02     0.0   1.0000  
## elevation_m 3.175e-02  1.380e-02     2.3   0.0242 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1202 on 74 degrees of freedom
## Multiple R-squared:  0.06674,    Adjusted R-squared:  0.05413 
## F-statistic: 5.292 on 1 and 74 DF,  p-value: 0.02424
## `geom_smooth()` using formula 'y ~ x'

eBird models (abudance & diversity residuals with time) with reciprocal climate & elevation residuals

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.103   1.375   1.534   1.576   1.773   2.436
## Joining, by = "elevation"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.781  23.706  33.047  35.525  47.104  86.071
## Joining, by = "elevation"
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -0.32398 -0.19838 -0.14467 -0.15773 -0.11486 -0.02888
ebirdModelA <- lm(ele_div_residuals ~  pc1, data = ebird_claycat_final) #model the residuals with elevation
summary(ebirdModelA)
## 
## Call:
## lm(formula = ele_div_residuals ~ pc1, data = ebird_claycat_final)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.21795 -0.36045 -0.09081  0.39884  1.16325 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.007015   0.078696  -0.089    0.929
## pc1         -0.029236   0.046110  -0.634    0.529
## 
## Residual standard error: 0.5227 on 43 degrees of freedom
## Multiple R-squared:  0.009263,   Adjusted R-squared:  -0.01378 
## F-statistic: 0.402 on 1 and 43 DF,  p-value: 0.5294
## `geom_smooth()` using formula 'y ~ x'

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -31.920 -13.372  -5.441  -7.370  -1.039  11.658
ebirdModelA <- lm(ele_abun_residuals ~  pc1, data = ebird_claycat_final) #model the residuals with elevation
summary(ebirdModelA)
## 
## Call:
## lm(formula = ele_abun_residuals ~ pc1, data = ebird_claycat_final)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -62.001 -14.886  -4.375   9.285 133.771 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  -0.3949     4.5926  -0.086    0.932
## pc1          -1.6460     2.6909  -0.612    0.544
## 
## Residual standard error: 30.5 on 43 degrees of freedom
## Multiple R-squared:  0.008627,   Adjusted R-squared:  -0.01443 
## F-statistic: 0.3742 on 1 and 43 DF,  p-value: 0.544
## `geom_smooth()` using formula 'y ~ x'

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -0.1660 -0.1577 -0.1573 -0.1577 -0.1565 -0.1533
ebirdModelA <- lm(pc1_div_residuals ~  elevation, data = ebird_claycat_final) #model the residuals with elevation
summary(ebirdModelA)
## 
## Call:
## lm(formula = pc1_div_residuals ~ elevation, data = ebird_claycat_final)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.2273 -0.3102 -0.1131  0.3905  1.2841 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  1.0004950  1.1184695   0.895    0.376
## elevation   -0.0003592  0.0004006  -0.897    0.375
## 
## Residual standard error: 0.5254 on 43 degrees of freedom
## Multiple R-squared:  0.01836,    Adjusted R-squared:  -0.004472 
## F-statistic: 0.8041 on 1 and 43 DF,  p-value: 0.3749
## `geom_smooth()` using formula 'y ~ x'

##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## -22.2285  -7.2992  -6.6624  -7.3704  -5.1049   0.6259
ebirdModelA <- lm(pc1_abun_residuals ~  elevation, data = ebird_claycat_final) #model the residuals with elevation
summary(ebirdModelA)
## 
## Call:
## lm(formula = pc1_abun_residuals ~ elevation, data = ebird_claycat_final)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -64.343 -15.356  -3.247  10.403 134.219 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) 101.31672   66.61815   1.521    0.136
## elevation    -0.03638    0.02386  -1.525    0.135
## 
## Residual standard error: 31.29 on 43 degrees of freedom
## Multiple R-squared:  0.05128,    Adjusted R-squared:  0.02922 
## F-statistic: 2.324 on 1 and 43 DF,  p-value: 0.1347
## `geom_smooth()` using formula 'y ~ x'

PCA of ebird checklist climate data: as elevation increases, pc1/aridity decreases

## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
## 
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## Warning: package 'scales' was built under R version 4.2.1

## `geom_smooth()` using formula 'y ~ x'

PCA of caterpillar site climate data: as elevation increases, pc1/aridity decrease

#Plot
ggbiplot::ggbiplot(pca)

ggplot(data = CompleteData, aes(x = elevation_m, y = pc1))+ 
  geom_point(size=6) +
  geom_smooth(colour="black",size =2,show.legend = F,method= "lm", se=FALSE)+
  theme(text = element_text(size=25))+
  labs(x= "Elevation", y = "PC1") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
## `geom_smooth()` using formula 'y ~ x'