说示例数据
library("robustbase")
data(education)
我创建回归模型
model=lm(Y~X1+X2+X3,data=education)
现在我需要得到带有置信区间的预测值的图。 即,我想要这样的情节:
如何创建它?
model=lm(Y~X1+X2+X3,data=education)
plot(model, which = 1)
我的结果不需要。
答案 0 :(得分:1)
您可以将lattice
软件包与mosaic
软件包一起使用,例如
library("lattice")
library(mosaic)
library(robustbase)
data(education)
mylm=lm(Y~X1+X2+X3,data=education)
pred <- predict(mylm, data=education)
df <- data.frame(Observed=education$Y, Predicted=pred)
xyplot(Predicted ~ Observed, data = df, pch = 19, panel=panel.lmbands,
band.lty = c(conf =2, pred = 1))