Reputation: 177
Say example data
library("robustbase")
data(education)
I create regression model
model=lm(Y~X1+X2+X3,data=education)
Now i need get plot where predicted values with confidence interval. I.e., I want such plot:
How can I create it?
model=lm(Y~X1+X2+X3,data=education)
plot(model, which = 1)
It is not needed for me result.
Upvotes: 2
Views: 1612
Reputation: 8136
You can use lattice
package with mosaic
package for that, like
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))
Upvotes: 1