首页 文章

找到abline与拟合曲线的交点

提问于
浏览
0

我使用以下代码绘制了一条逻辑曲线:

数据: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 $ Mature.Ind:int 0 0 6 5 3 2 1 0 1 2图(L50 $ Mature.Ind / L50 $ Total.Ind~L50 $ Length.Class,data = L50,pch = 20,xlab =“Length class(cm)”,ylab =“成熟个体的比例”)glm .out <-glm(cbind(L50 $ Mature.Ind,L50 $ Total.Ind-L50 $ Mature.Ind)~L50 $ Length.Class,family = binomial(logit),data = L50)glm.out Call:glm (formula = cbind(L50 $ Mature.Ind,L50 $ Total.Ind - L50 $ Mature.Ind)~L50 $ Length.Class,family = binomial(logit),data = L50)Coefficients :( Intercept)L50 $ Length . 等级-8.6200 0.1053自由度:8总计(即空); 7剩余空间偏差:38.14剩余偏差:9.924 AIC:23.4行(L50 $ Length.Class,glm.out $ fit,type =“l”,col =“red”,lwd = 2)abline(h = 0.5,col = “黑”,LTY = 2,LWD = 2)

我得到以下曲线:
enter image description here

问题是我需要在拟合曲线上找到对应于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))

1 回答

  • 2

    你的系数表示 y = -8.62 + 0.1053x ,所以 x = (glm.out$family$linkfun(.5)+8.62)/ 0.1053 . 话虽如此,您可能希望使用记录良好的函数,例如 MASS 包中的 dose.p(myFit, 0.5) ,这样您也会得到标准错误等 .

相关问题