Perhaps this will be quick for some of you but I would like to represent the standard error of the regression using plot().
So, if I have a data like this:
x1 <- 1:500
b0 <- 17
b1 <- 0.5
sigma <- 7
er <- rnorm(x1,0,sigma)
y <- b0 + b1*x1 + er
model1 <- lm(y~x1)
plot(x1,y)
abline(model1,col="red",lwd=5)
How could I represent the standard error, in lines, for that regression?
Thanks in advance!



lines(x1[order(x1)], predict(model1, interval = "confidence")[, "lwr"][order(x1)]); lines(x1[order(x1)], predict(model1, interval = "confidence")[, "upr"][order(x1)])