data= read.csv("file:///D:/From Syncplicity/Bulk_Papers/IMP_Papers/TOG Papers/JA_AL/aa.csv")
#fit linear regression
model<-lm(y~x, data=data)
## compute confidence bands (for all data)
pred.c <- predict(model, data, interval="confidence")
## set up regression plot (plot nothing here; only set up range, axis)
ylim <- range(range(pred.c[,-1]))
plot(1:nrow(pred.c), numeric(nrow(pred.c)), col = "white", ylim = ylim,xaxt = "n", xlab = "Date", ylab = "prediction")
axis(1, at = 1:nrow(pred.c), labels = data$x)
## shade 95%-level confidence region
polygon(c(1:nrow(pred.c),nrow(pred.c):1), c(pred.c[, 2], rev(pred.c[, 3])), density=20,
col = "grey", border = NA)
## add 95%-level confidence bands
lines(1:nrow(pred.c), pred.c[, 2], col = 2, lty = 2, lwd = 2)
lines(1:nrow(pred.c), pred.c[, 3], col = 2, lty = 2, lwd = 2)
