Skip to content
Prev 307356 / 398506 Next

How to use Lines function to draw the error bars?

If you had provided reproducible code, you would already have your answer.
You should spend a few hours with one or more of the freely available R
tutorials. In your original post you have the line:

prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95)

?predict.lm tells you that the function returns a matrix (in your case prd)
so either of the following should work:

library(plotrix)

plotCI( x=1:15, y=prd$fit, ui=prd$upr, li=prd$lwr)

or

plotCI( x=1:15, y=prd[,1], ui=prd[,3], li=prd[,2])

This is very basic stuff.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352