library(readxl)
ab <- read_excel("bird.xlsx", sheet = "sp ab")
small <- read_excel("bird.xlsx", sheet = "smallsp ab")
## New names:
## * Species -> Species...1
## * SYDP -> SYDP...2
## * USYD -> USYD...3
## * `` -> ...5
## * `` -> ...6
## * … and 4 more problems
birds <- read_excel("bird.xlsx", sheet = "Sheet2")
count <- read_excel("bird.xlsx", sheet = "count")

str(count)
## Classes 'tbl_df', 'tbl' and 'data.frame':    21 obs. of  3 variables:
##  $ Location: chr  "SYDP" "TZ" "USYD" "SYDP" ...
##  $ Species : chr  "Willie Wagtail" "Willie Wagtail" "Willie Wagtail" "Welcome Swallow" ...
##  $ Count   : num  5 0 0 72 2 5 20 0 1 0 ...
sp <- as.factor(count$Species)
counts <- count$Count
miner <- as.factor(birds$Miner)

Visualise the data

Small species

boxplot(count$Count ~ count$Location)

barplot(birds$`Simpsons Evenness` ~ birds$Location)

TZ has the most evenness.

ANOVA

## Total count for each location

mod1 <- aov(Count ~ Location, data = count)
summary(mod1)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Location     2   1049   524.3   2.327  0.126
## Residuals   18   4056   225.3
anova(mod1)
## Analysis of Variance Table
## 
## Response: Count
##           Df Sum Sq Mean Sq F value Pr(>F)
## Location   2 1048.7  524.33  2.3268 0.1263
## Residuals 18 4056.3  225.35
library(emmeans)
comp <- emmeans(mod1, "Location")
pairs(comp)
##  contrast    estimate   SE df t.ratio p.value
##  SYDP - TZ      14.14 8.02 18 1.763   0.2103 
##  SYDP - USYD    15.71 8.02 18 1.958   0.1515 
##  TZ - USYD       1.57 8.02 18 0.196   0.9791 
## 
## P value adjustment: tukey method for comparing a family of 3 estimates
plot(comp)

# Simpson's index with miner abundance as a factor
smp <- aov(birds$`Simpsons Index` ~ as.factor(birds$Miner) + birds$Location, data = birds)
summary(smp)
##                        Df  Sum Sq Mean Sq
## as.factor(birds$Miner)  2 0.04059 0.02029
smp1 <- aov(`Simpsons Index` ~ Miner, data = birds)
anova(smp1)
## Warning in anova.lm(smp1): ANOVA F-tests on an essentially perfect fit are
## unreliable
## Analysis of Variance Table
## 
## Response: Simpsons Index
##           Df   Sum Sq  Mean Sq F value Pr(>F)
## Miner      2 0.040588 0.020294               
## Residuals  0 0.000000
anova(smp)
## Warning in anova.lm(smp): ANOVA F-tests on an essentially perfect fit are
## unreliable
## Analysis of Variance Table
## 
## Response: birds$`Simpsons Index`
##                        Df   Sum Sq  Mean Sq F value Pr(>F)
## as.factor(birds$Miner)  2 0.040588 0.020294               
## Residuals               0 0.000000
# no p-value = p = 1.0


mod2 <- lm(birds$`Total Birds` ~ birds$Miner + birds$`Simpsons Index`, data = birds)
anova(mod2)
## Warning in anova.lm(mod2): ANOVA F-tests on an essentially perfect fit are
## unreliable
## Analysis of Variance Table
## 
## Response: birds$`Total Birds`
##             Df Sum Sq Mean Sq F value Pr(>F)
## birds$Miner  2 7340.7  3670.3               
## Residuals    0    0.0
summary(mod2)
## 
## Call:
## lm(formula = birds$`Total Birds` ~ birds$Miner + birds$`Simpsons Index`, 
##     data = birds)
## 
## Residuals:
## ALL 3 residuals are 0: no residual degrees of freedom!
## 
## Coefficients: (1 not defined because of singularities)
##                        Estimate Std. Error t value Pr(>|t|)
## (Intercept)                   2         NA      NA       NA
## birds$MinerLOW              110         NA      NA       NA
## birds$MinerMEDIUM            11         NA      NA       NA
## birds$`Simpsons Index`       NA         NA      NA       NA
## 
## Residual standard error: NaN on 0 degrees of freedom
## Multiple R-squared:      1,  Adjusted R-squared:    NaN 
## F-statistic:   NaN on 2 and 0 DF,  p-value: NA

Abundance of each small species at each site

library(readxl)
abprop <- read_excel("bird.xlsx", sheet = "abprop")
## New names:
## * `` -> ...5
## * `` -> ...6
## * `` -> ...7
prop1 <- read_excel("bird.xlsx", sheet = "Sheet5")

boxplot(prop1$Abundance ~ prop1$Location)

boxplot(prop1$Abundance ~ prop1$Species, las = 2, xlab = "")

ANOVA

prop.aov <- aov(prop1$Abundance ~ prop1$Location + prop1$Species)
anova(prop.aov)
## Analysis of Variance Table
## 
## Response: prop1$Abundance
##                Df  Sum Sq  Mean Sq F value   Pr(>F)   
## prop1$Location  2 0.00000 0.000000  0.0000 1.000000   
## prop1$Species   7 0.91225 0.130321  5.8633 0.002489 **
## Residuals      14 0.31117 0.022227                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(emmeans)
compr <- emmeans(prop.aov, "Species")
pairs(compr)
##  contrast                                          estimate    SE df
##  Australian Reed Warbler - Fairy Martin           -0.049607 0.122 14
##  Australian Reed Warbler - Noisy Miner            -0.607626 0.122 14
##  Australian Reed Warbler - Spotted Pardalote      -0.008708 0.122 14
##  Australian Reed Warbler - Superb Fairywren       -0.026585 0.122 14
##  Australian Reed Warbler - Welcome Swallow        -0.220463 0.122 14
##  Australian Reed Warbler - White-browed Scrubwren -0.062471 0.122 14
##  Australian Reed Warbler - Willie-wagtail         -0.008180 0.122 14
##  Fairy Martin - Noisy Miner                       -0.558018 0.122 14
##  Fairy Martin - Spotted Pardalote                  0.040900 0.122 14
##  Fairy Martin - Superb Fairywren                   0.023023 0.122 14
##  Fairy Martin - Welcome Swallow                   -0.170856 0.122 14
##  Fairy Martin - White-browed Scrubwren            -0.012864 0.122 14
##  Fairy Martin - Willie-wagtail                     0.041427 0.122 14
##  Noisy Miner - Spotted Pardalote                   0.598918 0.122 14
##  Noisy Miner - Superb Fairywren                    0.581041 0.122 14
##  Noisy Miner - Welcome Swallow                     0.387163 0.122 14
##  Noisy Miner - White-browed Scrubwren              0.545155 0.122 14
##  Noisy Miner - Willie-wagtail                      0.599446 0.122 14
##  Spotted Pardalote - Superb Fairywren             -0.017877 0.122 14
##  Spotted Pardalote - Welcome Swallow              -0.211755 0.122 14
##  Spotted Pardalote - White-browed Scrubwren       -0.053763 0.122 14
##  Spotted Pardalote - Willie-wagtail                0.000528 0.122 14
##  Superb Fairywren - Welcome Swallow               -0.193878 0.122 14
##  Superb Fairywren - White-browed Scrubwren        -0.035886 0.122 14
##  Superb Fairywren - Willie-wagtail                 0.018405 0.122 14
##  Welcome Swallow - White-browed Scrubwren          0.157992 0.122 14
##  Welcome Swallow - Willie-wagtail                  0.212283 0.122 14
##  White-browed Scrubwren - Willie-wagtail           0.054291 0.122 14
##  t.ratio p.value
##  -0.408  0.9999 
##  -4.992  0.0036 
##  -0.072  1.0000 
##  -0.218  1.0000 
##  -1.811  0.6234 
##  -0.513  0.9994 
##  -0.067  1.0000 
##  -4.584  0.0075 
##   0.336  1.0000 
##   0.189  1.0000 
##  -1.404  0.8416 
##  -0.106  1.0000 
##   0.340  1.0000 
##   4.920  0.0041 
##   4.773  0.0054 
##   3.181  0.0915 
##   4.478  0.0091 
##   4.924  0.0041 
##  -0.147  1.0000 
##  -1.740  0.6650 
##  -0.442  0.9998 
##   0.004  1.0000 
##  -1.593  0.7474 
##  -0.295  1.0000 
##   0.151  1.0000 
##   1.298  0.8854 
##   1.744  0.6625 
##   0.446  0.9997 
## 
## Results are averaged over the levels of: Location 
## P value adjustment: tukey method for comparing a family of 8 estimates
plot(compr)

#Miner Abundance as 3 levels Low, medium and high.

miner <- as.factor(prop1$`Miner Abundance`)
prop1.aov <- aov(prop1$Abundance ~ prop1$`Miner Abundance` + prop1$Location)

anova(prop1.aov)
## Analysis of Variance Table
## 
## Response: prop1$Abundance
##                         Df   Sum Sq  Mean Sq F value Pr(>F)
## prop1$`Miner Abundance`  1 0.034814 0.034814  2.8097 0.1101
## prop1$Location           1 0.015818 0.015818  1.2766 0.2726
## Residuals               19 0.235423 0.012391

Miner Abundance as a proportion compared to abundance of other species present at that site

minerab <- read_excel("bird.xlsx", sheet = "Sheet5")

miner.aov <- aov(minerab$Abundance ~ minerab$Species + minerab$Location + minerab$`Miner Abundance`)

anova(miner.aov)
## Analysis of Variance Table
## 
## Response: minerab$Abundance
##                  Df   Sum Sq   Mean Sq F value  Pr(>F)  
## minerab$Species   7 0.169963 0.0242805  3.3026 0.03359 *
## minerab$Location  2 0.027868 0.0139342  1.8953 0.19262  
## Residuals        12 0.088223 0.0073519                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Abundance is impacted by species composition (p value = 0.0335). Location is not significant.

Check assumptions.

# check assumptions
plot(miner.aov)
## Warning: not plotting observations with leverage one:
##   7

## Warning: not plotting observations with leverage one:
##   7

smallsp <- lm(minerab$Abundance ~ minerab$`Miner Abundance` + minerab$Species + minerab$Location)

anova(smallsp)
## Analysis of Variance Table
## 
## Response: minerab$Abundance
##                           Df   Sum Sq  Mean Sq F value  Pr(>F)  
## minerab$`Miner Abundance`  1 0.034814 0.034814  4.7353 0.05024 .
## minerab$Species            7 0.157897 0.022557  3.0681 0.04257 *
## minerab$Location           1 0.005121 0.005121  0.6966 0.42024  
## Residuals                 12 0.088223 0.007352                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1