Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: What is the best way to graph CI bands that partially overlap?

From   "Newson, Roger B" <>
To   <>
Subject   st: RE: What is the best way to graph CI bands that partially overlap?
Date   Mon, 10 Jul 2006 12:30:14 +0100

A possible solution is offered by the -eclplot- package, (downloadable
from SSC), which has a -supby()- option to allow superimposed confidence
interval plots. The -supby()- option has suboptions -spaceby- and
-offset-, allowing the user to space the different superimposed plots so
the confidence intervals do not overwrite each other and cause
confusion. -eclplot- also offers many types of confidence interval plot,
using the -eplottype()- option and the -rplottype()- option to define 7
ways of plotting estimates and 8 ways of plotting confidence limits,
which can be combined to give 7*8=56 possible combinations. The most
popular combinations are probably the default -eplottype(scatter)
rplottype(rcap)- (whic gives conventional CI plots with a symbol and a
whisker) and the alternative -eplottype(bar) rplottype(rcap)- (which
gives detonator plots).

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
TELEPHONE: +44 (0)20 7352 8121 ext 3381
FAX: +44 (0)20 7351 8322
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute at Imperial College London
Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR

Opinions expressed are those of the author, not of the institution.

-----Original Message-----
[] On Behalf Of Joseph
Sent: 10 July 2006 09:21
To: Statalist
Subject: st: What is the best way to graph CI bands that partially

Plotting the confidence interval as a tinted band around the prediction
seems to be a good way to present the model fit, and that is what
does.  A problem arises when plotting two categories' or groups' model
on the same graph.  Wherever the CI bands overlap, the CI band of the
fit plotted will obscure the earlier one's.

Using -twoway rline- is an alternative, but it gives rise to a graph
six lines for two treatment groups (two prediction lines and two sets
of upper and lower confidence limit lines).  Even with softening of the
lines (reduced intensity, line thickness, etc.), the graph looks crowded
requires more audience effort.

One approach I've seen recently is to separately plot the overlapping
regions in a mixed color.  Say, the CI band of the first plot is blue
that of the second is red, then the overlapping region is plotted in
I cannot recall where I saw the example of this approach, but it seems
doable in Stata, using indicator variables for flagging when the lower
CL of
one fit is less than the upper CL of the other, and then overlaying
a -twoway rarea ucl1 lcl2 x if flag-, or something similar.  It seems
cumbersome, though, and flagging could get complicated if the
cross, such as with an interaction.

I suppose that another alternative for categorical predictors would be
use a connected-symbols or bars for the predictions with an overlaid
range-spike-with-cap for the CI.  This, too, would seem to make for an
overly busy graph if there are more than just a couple of categories in
predictor, and doesn't seem ideal if the categories are samplings of an
underlying predictor that is inherently continuous (time, drug

Is there a consensus, or even a plurality, of opinion how best to depict
model fits including CIs when there is some overlapping of the CIs?

Joseph Coveney

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index