---
# System prepended metadata

title: Ecology of exceptionally large bat colonies – Biotropica BITR-22-202.R1

---

# Ecology of exceptionally large bat colonies – Biotropica BITR-22-202.R1
---

Models and Graphics of the Residue Distribution

## Description of the data and file structure

We used presence e absence data from the bat species to analyze, using mvabund package, the relationship with the caves characteristics. The data is organized in a spreadsheet containing in each column the values for the caves features, followed by the data of presence/absence of each species. The file “mvabund” was used as an input in R on the script described below.



## Code/Software

Comp<-read.csv2(file="mvabund.csv",sep=";",header=T,dec=",", strip.white = T, na.strings = "")
Comp
str(Comp)
summary(Comp)
library(mvabund)
Abun_spp <- mvabund(Comp[,23:40])
par(mar=c(2,10,2,2))
boxplot(Comp[,23:40],horizontal = TRUE,las=2, main="Abundance")
meanvar.plot(Abun_spp)


Abun_spp_pa <- Abun_spp
Abun_spp_pa[Abun_spp_pa>0] = 1
Abun_spp_pa 

cave <- manyglm(Abun_spp ~ Comp$HP*Comp$ESI,
           	family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)

cave
plot(cave)
summary(cave, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(cave)
anova(cave, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")

cave1 <- manyglm(Abun_spp ~ Comp$Dom*Comp$Hol*Comp$Cre, 
family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)
cave1
plot(cave1)
summary(cave1, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(cave1)
anova(cave1, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")

env <- manyglm(Abun_spp ~ Comp$Tave*Comp$Uave*Comp$Uvar*Comp$Tvar,
family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)
env
plot(env)
summary(env, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(env)
anova(env, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")


env1 <- manyglm(Abun_spp ~ Comp$Tave*Comp$Uave,
family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)
env1
plot(env1)
summary(env1, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(env1)
anova(env1, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")

env2 <- manyglm(Abun_spp ~ Comp$Uvar*Comp$Tvar,
family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)
env2
plot(env2)
summary(env2, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(env2)
anova(env2, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")

env3 <- manyglm(Abun_spp ~ Comp$HP * Comp$ESI * Comp$Tave * Comp$Uave,
family = "binomial", K = 1,
x = TRUE, y = TRUE, qr = TRUE, show.coef = TRUE, show.fitted = TRUE, show.residuals = TRUE)
env3
plot(env3)
summary(env3, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")
anova(env3)
anova(env3, resamp = "montecarlo", test = "LR", p.uni = "unadjusted")



