求出拟合曲线的斜线的交点 [英] find the intersection of abline with fitted curve

查看:181
本文介绍了求出拟合曲线的斜线的交点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I plotted a logistic curve with its fit using the following codes:

数据:L50

data:L50

str(L50)

"data.frame":10磅.的3个变量:

'data.frame': 10 obs. of 3 variables:

$ Length.Class:int 50 60 70 80 90 100 110 120 130 140

$ 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

$ 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

$ Mature.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,家庭=二项式(logit),数据= L50)

glm.out Call: glm(formula = 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

Coefficients: (Intercept) L50$Length.Class
-8.6200 0.1053

自由度:总计8(即无效); 7残留 空偏差:38.14 残余偏差:9.924 AIC:23.4

Degrees of Freedom: 8 Total (i.e. Null); 7 Residual Null Deviance: 38.14 Residual Deviance: 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轴上的值绘制一条线段....对此有任何帮助吗? 谢谢

The question is that i need to find the point that corresponds to Y=0.5 on the fitted curve and draw a line segment through it with its value on the x-axis....Any help with that? Thank you

这是你的要求

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

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

推荐答案

您的系数表示y = -8.62 + 0.1053x,所以x = (glm.out$family$linkfun(.5)+8.62)/ 0.1053.话虽如此,您可能希望使用文档完善的功能,例如MASS软件包中的dose.p(myFit, 0.5),这样您还可以获得标准错误等.

Your coefficients say that y = -8.62 + 0.1053x, so x = (glm.out$family$linkfun(.5)+8.62)/ 0.1053. Having said that, you'll probably want to use a well documented function, such as dose.p(myFit, 0.5) from the MASS package, so that you also get standard errors etc.

这篇关于求出拟合曲线的斜线的交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆