我目前正在进行一项涉及不同种类蝙蝠和栖息地破碎化的研究。我的数据集包含存在数据(1 = 存在,0 = 不存在)和关于片段大小、体重(均连续)和饲养行会(Feeding.Guild;分类,6 个级别:食肉动物、食果动物、食虫动物、蜜食动物、杂食动物和食血动物的数据)。使用自然对数转换碎片大小 (logFrag) 和体质量 (logMass) 以符合正态分布。由于被分类,我无法提供完整的数据集 (bats2)。
为了分析这些数据,我使用逻辑回归。在 R 中,这是具有二项式族的 glm 函数。
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)
Run Code Online (Sandbox Code Playgroud)
这个回归的结果是通过summary()
函数得到的,如下。
Coefficients:
Estimate Std. Error z value …
Run Code Online (Sandbox Code Playgroud)