[英]Turning a proportion of responses into binary response variable for logistic regression in R
[英]plot phylogenetic logistic regression with binary response variable
使用來自?phyloglm
的示例:
library(ape)
library(phylolm)
set.seed(123456)
tre = rtree(50)
x = rTrait(n=1,phy=tre)
X = cbind(rep(1,50),x)
y = rbinTrait(n=1,phy=tre, beta=c(-1,0.5), alpha=1 ,X=X)
dat = data.frame(trait01 = y, predictor = x)
fit = phyloglm(trait01~predictor,phy=tre,data=dat,boot=100)
繪制(抖動的)數據和響應( plogis()
是邏輯函數。預測值為logistic(a+b*x)
;我們使用帶有add=TRUE
curve()
畫線)
par(las=1,bty="l") ## cosmetic
plot(x,jitter(y,factor=0,amount=0.02),
xlab="trait",ylab="response",xlim=c(-3.5,3.5))
cc <- coef(fit)
curve(plogis(cc[1]+cc[2]*x),col="red",add=TRUE)
該圖的OP版本為
哪一個(盡管我們看不到y軸刻度)與對數擬合完全一致,在預測值的中間范圍內大致呈線性關系(在曲線的上端有減速跡象)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.