问题描述
不幸的是,在Stack上解决此问题的其他解决方案对我没有用。我正在尝试在Logistic回归的R-studio中绘制广义线性模型。我可以绘制预测线,但是在添加置信区间(对于95%置信度)方面存在问题
基本上我有我的模型:
Model <- glm(Response ~ Factor,data = MyData,family="binomial"(link = logit))
然后从那里创建一个数据框,让我的预测位于其中:
d.frame <- data.frame(Factor=(10:120))
prediction.data <- with(MyData,d.frame)
predictions <- predict(Model,newdata = prediction.data,type = "link",se.fit = TRUE)
我认为这部分是正确的,因此我可以在每次预测时使用标准误差来计算我的C.I。 从那里,我使用临界值为1.96的95%来计算CI。
critical.val <- 1.96
upper <- predictions$fit + (critical.val * predictions$se.fit)
lower <- predictions$fit - (critical.val * predictions$se.fit)
fit <- predictions$fit
这是我尝试绘制线条的方法:
with(O.Ring.Data,plot(Temperature,Failure,type="n",ylim=c(-0.2,1.2),xlim = c(10,120),ylab = "Response",xlab="Factor"))
lines(prediction.data$Factor,prediction.data$upr,col="red",lty=2,lwd=2)
lines(prediction.data$Factor,prediction.data$lwr,prediction.data$fit,lwd=2)
但是从此代码来看,我的图形上没有用于预测的行。 对我的代码中的错误有任何建议吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)