Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 为什么我的二项式GLM有多条预测线?_R_Plot_Glm_Predict - Fatal编程技术网

R 为什么我的二项式GLM有多条预测线?

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

我的数据是以千克为单位的后代质量,以及一列1和0来表示母亲是否在她生命的最后一年

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")

太棒了!这很有效,谢谢。有时候,很明显的事情让你着迷。太棒了!这很有效,谢谢。有时候,真正让你着迷的是那些显而易见的事情。