0

I looked over the tutorial in R for prediction and decided to reword my question. I need the prediction on average for male with a 95%CI then repeat with maximal values using the variables status, income and verbal. Now If I did the predictions correctly shown below with the mean then the max values. But doesn't that give 2 prediction intervals and 2 confident intervals for both the average and max. values

 g2<-data.frame(status=75, income=15, verbal=10, sex=0)
 g1<-data.frame(status=43, income=4.64, verbal=6.66, sex=0)

ie..Average

> g1<-data.frame(status=43, income=4.64, verbal=6.66, sex=0)
> predict(g,g1, interval='confidence', level=.90)
fit lwr upr
1 28.11506 19.7603 36.46983
> predict(g,g1, interval='prediction', level=.90)
fit lwr upr
1 28.11506 -10.95281 67.18293

Max Values used:

> predict(g,g2, interval='confidence', level=.90)
       fit      lwr      upr
1 71.30794 47.07516 95.54072
> predict(g,g2, interval='prediction', level=.90)
       fit      lwr      upr
1 71.30794 26.10037 116.5155

Do I need both the prediction and confidence interval?

Question: how do I plot the CI to determine which is wider?

smillig
  • 2,336
  • 28
  • 31
MsSnowy
  • 101
  • 2
  • 4
  • 6
  • I tried to follow the plot as in book but I get this error: `str(predict(g,g1, se=TRUE)) List of 4 $ fit : Named num 28.1 ..- attr(*, "names")= chr "1" $ se.fit : num 4.97 $ df : int 42 $ residual.scale: num 22.7 > grid matplot(grid, p$fit, lty=c(1,2,2) xlab="average", ylab="male") Error in p$fit : $ operator is invalid for atomic vectors` – MsSnowy Sep 26 '12 at 22:29
  • 1
    You seem to be confusing `P` and `p`: because `R` is case-sensitive, these are two different things, whence the error message. You must pay attention to details! – whuber Sep 27 '12 at 02:02

1 Answers1

2

Do I need both the prediction and confidence interval?

It depends on the question you've been asked for this homework. A confidence interval tells you about the likely location of the true population parameter (you may recall that you are fitting a mean to a sample of data), whereas a prediction interval is about the distribution of individual data points, specifically newly sampled observations.
(Sidenote: They both differ from a tolerance interval.)

In sum, are you interested in getting an interval for future observations or not? The beginning of your question speaks of itself.

Related threads (besides https://stats.stackexchange.com/q/37959/930):

(which also suggest you may want to have a look at past threads on this site before asking close to duplicate question.)

Note also that you asked for a 90% CI in your code (level=.90), not a 95% CI as stated at the beginning of your question.

Question: how do I plot the CI to determine which is wider?

You don't need to plot them to verify which one is larger. Theory and intuition already tell you that: would you be more confident with what you estimated from observed data, or from unseen statistical units?

In any case, there is an example of plotting confidence interval in R on-line help, see help(predict.lm); however, as pointed out by @whuber in his comment, you must be careful with object names in R because R is case-sensitive.

chl
  • 50,972
  • 18
  • 205
  • 364
  • 1
    May I suggest @jerry (formerly michelle) and you, MsSnowy, and probably others, that you coordinate together in order to gather related homework questions and ask unique and precise questions as suggested in our [FAQ](http://stats.stackexchange.com/faq). Registering your account would be a plus :-) – chl Sep 27 '12 at 08:49
  • I corrected the level to reflect 95%. The question was to compare both CI @ 95%-the one with "mean" and the other with "max" values and determine which is wider. – MsSnowy Sep 27 '12 at 15:55
  • So your question was unclear in this respect or I didn't read it correctly. I'll try to update the 2nd part of my answer to reflect this. (Anyway, when asking question you must supply as much information as possible in order to minimize the number of assumptions that users have to make.) – chl Sep 27 '12 at 16:02
  • I understand, so just my observing the values obtained above for the two intervals. Maximal values will produce wider bands in the CI. – MsSnowy Sep 27 '12 at 17:23