I'm currently working on a research involving different species of bats and fragmentation of the habitat. My dataset contains presence data (1 = present, 0 = absent) and data on the fragment sizes, body mass (both continuous) and feeding guilds (Feeding.Guild; categorical, 6 levels: carnivore, frugivore insectivore, nectarivore, omnivore and sanguinivore). The fragment sizes (logFrag) and body masses (logMass) are transformed using the natural log to conform to the normal distribution. I can't present the full data set (bats2) due to being classified.
To analyse this data, I use logistic regression. In R, this is the glm function with the binomial family.
bats2 <- read.csv("Data_StackExchange.csv",
quote = "", sep=";", dec = ".", header=T, row.names=NULL)
bats2$presence <- ifelse(bats2$Corrected.Abundance == 0, 0, 1)
bats2$logFrag <- log(bats2$FragSize)
bats2$logMass <- log(bats2$Mass)
str(bats2$Feeding.Guild)
Factor w/ 6 levels "carnivore","frugivore",..: 6 1 5 5 2 2 2 2 2 2 ...
levels(bats2$Feeding.Guild)
[1] "carnivore" "frugivore" "insectivore" "nectarivore" "omnivore" "sanguinivore"
regPresence <- glm(bats2$presence~(logFrag+logMass+Feeding.Guild),
family="binomial", data=bats2)
The results of this regression are obtained by the summary()
function and are as follows.
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.47240 0.64657 -6.917 4.61e-12 ***
logFrag 0.10448 0.03507 2.979 0.002892 **
logMass 0.39404 0.09620 4.096 4.20e-05 ***
Feeding.Guildfrugivore 3.36245 0.49378 6.810 9.78e-12 ***
Feeding.Guildinsectivore 1.97198 0.51136 3.856 0.000115 ***
Feeding.Guildnectarivore 3.85692 0.55379 6.965 3.29e-12 ***
Feeding.Guildomnivore 1.75081 0.51864 3.376 0.000736 ***
Feeding.Guildsanguinivore 1.73381 0.56881 3.048 0.002303 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
My first question is to verify that I interpret this data correctly: how to interpret this data correctly? I used this website to aid me in interpreting.
Additionally, I tried plotting this data in order to visualise it. However, when adding the facet_wrap function to make seperate plots for the different feeding guilds, the intercepts and slopes change compared to colouring the different feeding guilds in one plot. I used the following code:
Plot 1:
library(ggplot2)
qplot(logFrag, bats2$presence, colour=Feeding.Guild, data=bats2, se=F) +
geom_smooth(method = glm, family = "binomial", se=F, na.rm=T) + theme_bw()
Plot 2:
qplot(logFrag, bats2$presence, data=bats2, se=F) + facet_wrap(~Feeding.Guild,
scales="free") +
geom_smooth(method = glm, family = "binomial", se=F, na.rm=T) + theme_bw()
Resulting in the following images:
What causes these differences and which one would be the correct one?
Sample data set (part of data set which is not classified).