I was playing around with ggplot2 using the following commands to fit a line to my data:

ggplot(data=datNorm, aes(x=Num, y=Val)) + geom_point() + 
stat_summary(fun.data = "mean_cl_boot", geom="errorbar", colour="red", width=0.8) + 
stat_sum_single(median) + 
stat_sum_single(mean, colour="blue") + 
geom_smooth(level = 0.95, aes(group=1), method="lm")

The red dots are median values, blue are the means and the vertical red lines show the error bars. As a final step, I used geom_smooth to fit a line using linear smoothing so I used method="lm". Along with the line, a dull shade was generated as well around the line. While I figured out how to remove it from the documentation, the option I used to turn it off is:

se: display confidence interval around smooth? 

Can someone please tell me what I am supposed to understand from the shade around the line? Specifically, I am trying to understand how to interpret it. It must be some goodness-of-fit for the line perhaps but any extra information could be very useful to me. Any suggestions?

enter image description here


1 Answer 1


I suspect it means very little in your actual figure; you have drawn a form of stripplot/chart. But as we don't have the data or reproducible example, I will just describe what these lines/regions show in general.

In general, the line is the fitted linear model describing the relationship $$\widehat{\mathrm{val}} = \beta_0 + \beta_1 \mathrm{Num}$$ The shaded band is a pointwise 95% confidence interval on the fitted values (the line). If you repeatedly reran the data collection and analysis, 95% of the confidence intervals created during those repeats would contain the true, population, regression line. It shows us the uncertainty inherent in our estimate of the true relationship between your response and the predictor variable.

  • $\begingroup$ Thank you for your response and time. I will spend some time understanding your first comment on why it means little in my chart. Instead of drawing a bar plot with the mean, I drew a strip chart to get a glimpse of how many points were used as well. But please correct me if I am mistaken. My last question would be if there is a relation between this 95% confidence interval and the 95% confidence interval shown by the error bars. Specifically, what does it mean for the fitted line to be above or below the error bars? Or are they totally independent and should be interpreted separately? $\endgroup$
    – Legend
    Jul 26, 2011 at 7:51
  • $\begingroup$ If the x variate is categorical, it may not make sense to treat it as a 1 degree of freedom, linear term, which is how it has been treated in the computation of the fitted line. Also, your data do not appear to exhibit the constant variance assumption for the residuals of the model. The stripchart is not the issue, it is whether the regression of these data makes sense. The fitted line will be close to (or may even be, someone can correct me) a best fit line through the group means. $\endgroup$ Jul 26, 2011 at 7:58
  • $\begingroup$ Thank you very much for your insight. I will read more on the constant variance assumption for residuals. $\endgroup$
    – Legend
    Jul 26, 2011 at 23:55
  • 2
    $\begingroup$ Hmmm. I'm not completely sure your explanation is correct - the default is to draw a 95% point-wise confidence interval. I don't think that's quite the same thing as saying there's a 95% chance the true regression line lies within the shaded region. $\endgroup$
    – hadley
    Aug 31, 2011 at 0:46
  • $\begingroup$ @hadley slaps head yes, that would be a simultaneous confidence interval. Will update. $\endgroup$ Aug 31, 2011 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.