2014-04-07 41 views
0

我使用以下代碼標繪其配合的邏輯曲線:找到abline與擬合曲線的交點

數據:L50

str(L50)

'data.frame':10個OBS 。

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

$ Total.Ind:整數9 20 18 8 4 4 1 0 1 2

$成熟3個變量的.IND:整數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,家族=二項式(分對數),數據= L50)

係數: (截距)L50 $ Length.Class
-8.6200 0.1053

自由度:8合計(ie空值); 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)

我得到了以下曲線: enter image description here

的問題是,我需要找到擬合曲線上對應於Y = 0.5的點,並在其中繪製一條線,其值在x軸上....任何h用這個呢? 謝謝

這就是你問

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

回答

2

您係數說y = -8.62 + 0.1053x,所以x = (glm.out$family$linkfun(.5)+8.62)/ 0.1053。話雖如此,你可能會想使用一個有據可查的功能,如dose.p(myFit, 0.5)MASS包,所以你也可以得到標準錯誤等

+0

86是一個非常高的價值,如果你可以注意到從abline與擬合曲線相交。 – Myr

+0

好的 - 我建議給你的'dose.p'電話會給你什麼? –

+0

> dose.p(glm.out $嵌合,0.5) 錯誤UseMethod( 「家庭」): 應用於類的對象爲 '家庭' 無適用的方法 「C( '雙', '數字')」 – Myr