Skip to content
Prev 350713 / 398502 Next

Drawing the regression line and the 95% confidence intervals

Something like this?

# Compute the prediction limits and get their range to set ylim=
plim <- predict(LinearModel.1, interval = "prediction")
rnge <- c(min(plim[ , 2]), max(plim[ , 3]))
plot(GDP.per.head, fitted(LinearModel.1),ylim=rnge) 

# As before
devlm1<-lm(fitted(LinearModel.1)~GDP.per.head) 
abline(devlm1) 
conflm1<-confint(devlm1) 
abline(coef=conflm1[,1],lty=2) 
abline(coef=conflm1[,2],lty=2) 

# Plot the prediction limits
segments(GDP.per.head, plim[ , 2], GDP.per.head, plim[ , 3], col="gray")

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352


-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Cade, Brian
Sent: Wednesday, May 6, 2015 2:22 PM
To: varin sacha
Cc: R-help Mailing List
Subject: Re: [R] Drawing the regression line and the 95% confidence intervals

The prediction intervals are likely to be much wider than the confidence
intervals so you will need to be sure you scale the yaxis limits large
enough to see them.

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  cadeb at usgs.gov <brian_cade at usgs.gov>
tel:  970 226-9326
On Wed, May 6, 2015 at 12:59 PM, varin sacha <varinsacha at yahoo.fr> wrote:

            
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.