Re: [R] what's interesting to plot after predict.lm?

From: David Winsemius <>
Date: Wed, 23 Mar 2011 15:02:55 -0400

On Mar 23, 2011, at 12:04 PM, agent dunham wrote:

> Dear all,
> I've fitted this model with train data
> lms <- lm(vd ~ log(v1) + fv2+ fv5+ fv7 )
> and predicted over test data using
> plms <- predict.lm(lmsub, new=test,interval="predict",
> level=0.95,
> I've two questions:
> q1: what's the difference between writing interval "predict" or
> "confidence"
> ? How are they computed?

The source is readily accessible.

> Any reference would be appreciated

Any basic regression text should cover that topic. I know that Rosner did in its second edition 25 years ago and it's only a basic biostatistics text. I suspect you will also find that some of the contributed documentation has this covered. Wikipedia is not bad either.

> q2: What's interesting to plot? I've gone through another post, and
> have
> seen the following:
> (
> )
> plot( seq(0,6, length.out = 24), plmsub[ ,"fit"] )
> lines(seq(0,6, length.out = 24), plmsub[ ,"lwr"],
> lty=2)
> lines(seq(0,6, length.out = 24), plmsub[ ,"upr"],
> lty=2)
> But I don't know what to plot with my multiple linear regression.

It sounds like you need to read even more in an introductory text than just the section on the different between prediction and confidence intervals.

> I also tried plot(plms) but I guess it doesn't have too much sense

In my earlier reply I suggested it might not be what you expected, but I did not say the result would be nonsense.

> Maybe test$vd vs plms$fit? (if this was correct, what's the
> syntax to
> get the fit column of plms? )

You have three choices

--  to look at the structure of the lm-object with str()
--  read the help(lm) page and note the contents in the Value section
--  read the help(lm) page and identify the functions that will  
extract the feature of interest.

(The list is not the place to be asking questions about basic statistics questions.)

David Winsemius, MD
West Hartford, CT

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 23 Mar 2011 - 19:05:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Mar 2011 - 19:10:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive