我使用以下代码绘制了一条拟合的逻辑曲线:
数据:L50
str(L50)
'data.frame':10 obs。3个变量:
$ Length.Class:int 50 60 70 80 90 100 110 120 130 140
$ Total.Ind : int 9 20 18 8 4 4 1 0 1 2
$成熟.Ind:int 0 0 6 5 3 2 1 0 1 2
plot(L50$Mature.Ind/L50$Total.Ind ~ L50$Length.Class, data=L50,pch=20,xlab="Length class(cm)",ylab="Proportion of mature individuals")
glm.out<-glm(cbind(L50$Mature.Ind, L50$Total.Ind-L50$Mature.Ind) ~ L50$Length.Class,family=binomial(logit), data=L50)
glm.out
调用:glm(公式 = cbind(L50$Mature.Ind, L50$Total.Ind - L50$Mature.Ind) ~ L50$Length.Class, family = binomial(logit), data = L50)系数:(截距)L50$Length.Class
-8.6200 0.1053自由度:总共 8 个(即 Null);7 残余零偏差:38.14 残余偏差:9.924 AIC:23.4
lines(L50$Length.Class, glm.out$fitted,type="l", col="red",lwd=2)
abline(h=0.5,col="black",lty=2,lwd=2)
我得到以下曲线:
问题是我需要在拟合曲线上找到对应于 Y=0.5 的点并通过它绘制一条线段,其值在 x 轴上....有什么帮助吗?谢谢
这是你问的
dput(L50)
structure(list(Length.Class = c(50L, 60L, 70L, 80L, 90L, 100L,
110L, 120L, 130L, 140L), Total.Ind = c(9L, 20L, 18L, 8L, 4L,
4L, 1L, 0L, 1L, 2L), Mature.Ind = c(0L, 0L, 6L, 5L, 3L, 2L, 1L,
0L, 1L, 2L), MatF = c(0L, 0L, 1L, 4L, 1L, 2L, 0L, 0L, 1L, 2L), MatM = c(0L, 0L, 5L, 1L, 2L, 0L, 1L, 0L, 0L, 0L)), .Names = c("Length.Class",
"Total.Ind", "Mature.Ind", "MatF", "MatM"), class = "data.frame", row.names = c(NA,-10L))