R 为什么我的二项式GLM有多条预测线?
我的数据是以千克为单位的后代质量,以及一列1和0来表示母亲是否在她生命的最后一年R 为什么我的二项式GLM有多条预测线?,r,plot,glm,predict,R,Plot,Glm,Predict,我的数据是以千克为单位的后代质量,以及一列1和0来表示母亲是否在她生命的最后一年 Chick Mass Terminal Effect 3.4 0 3.1 1 2.4 1 3.6 0 等等 所以我建立了一个模型来评估体重(单位:kg)是否对死亡率有影响(二项式) m10打印前对预测值进行排序 使用带有一些变化的ir
Chick Mass Terminal Effect
3.4 0
3.1 1
2.4 1
3.6 0
等等
所以我建立了一个模型来评估体重(单位:kg)是否对死亡率有影响(二项式)
m10打印前对预测值进行排序
使用带有一些变化的iris数据集:
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")
打印前对预测值进行排序
使用带有一些变化的iris数据集:
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")
太棒了!这很有效,谢谢。有时候,很明显的事情让你着迷。太棒了!这很有效,谢谢。有时候,真正让你着迷的是那些显而易见的事情。