我的数据是后代的质量(以千克为单位),并用1和0的列表示母亲是否在末年。
Chick Mass Terminal Effect
3.4 0
3.1 1
2.4 1
3.6 0
等等..
因此,我有一个适合评估质量(以千克为单位)是否对死亡率(二项式)有影响的模型
m10 <-glm(Terminal_Effect~chick_mass, data = cranesData, family = binomial(link="logit"))
summary(m10)
plot(cranesData$Terminal_Effect~cranesData$chick_mass, xlab = "Chick Mass (kg)", ylab = "Probability of Mother Death", pch = 19)
当我绘制此图形时,我的图形上有多条线,是否可以将其更改为一条线?
任何帮助,将不胜感激 :)
在绘图之前对预测值进行排序。
使用可变的虹膜数据集:
set.seed(111)
dat = iris
dat$Species = as.numeric(dat$Species=="setosa")
dat$Petal.Width = dat$Petal.Width + rnorm(nrow(dat))
排序预测变量,在这种情况下,它是petal.width:
dat = dat[order(dat$Petal.Width),]
fit = glm(Species ~ Petal.Width,data=dat,family="binomial")
plot(dat$Species ~ dat$Petal.Width)
lines(dat$Petal.Width,fit$fitted.values,col="blue")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句