【问题标题】:linear regression predictions with confidence interval plot in RR中带有置信区间图的线性回归预测
【发布时间】:2020-03-02 18:38:16
【问题描述】:

说示例数据

library("robustbase")
data(education)

我创建回归模型

model=lm(Y~X1+X2+X3,data=education)

现在我需要绘制带有置信区间的预测值。 即,我想要这样的情节:

如何创建它?

model=lm(Y~X1+X2+X3,data=education)
plot(model, which = 1)

我不需要这个结果。

【问题讨论】:

标签: r


【解决方案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))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-29
    • 2019-01-22
    • 1970-01-01
    • 2022-01-13
    • 2014-07-03
    • 2018-02-05
    • 2010-11-13
    • 2016-12-12
    相关资源
    最近更新 更多