Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: RE: RE: how to add error bars to each data marker on a line graph (or the size of the data marker reflect the confidence interval)?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: RE: how to add error bars to each data marker on a line graph (or the size of the data marker reflect the confidence interval)?
Date   Fri, 18 Feb 2011 18:02:15 +0000 (GMT)

--- Xin Lu asked
> I have a data set with 15 rows and four columns: x | y |
> lower CI for y | upper CI for y.
> 
> I use the line graph to illustrate my data. So I would have
> 15 data markers connected by straight line segment. I need
> to put error bars (confidence interval for y) at each data
> point, or I could use the size of the data marker to reflect
> the confidence interval.

-- Zhiqiang Wang answered
> Assuming that your four variables are named as x, y, low and upper, try > the following: 
>
> .  sort x
> .  line y x || rcap low upper x 

--- On Fri, 18/2/11, Liao, Junlin asked:
> Interesting solution. But I fail to see that it solves
> the problem, especially if the y variable is categorical.
> Even if y is numeric, the chart is not meaningful, not
> what Xin wanted.

As far as I understand the original question, it exactly 
produces the graph that was asked for. It is obviously 
hard to describe in words how a graph should look like,
so misunderstanding can easily happen. For that reason
look at the graph when you run the example below in
Stata (I changed Zhiqiang's -line- to -twoway connected-
because Xin also asked for markers):

*------------ begin example -------------
drop _all
// create some data that would recreate
// the main features
set obs 15
gen y = rnormal()
sort y
gen x = _n
gen lb = y - 2
gen ub = y + 2

sort x
twoway connected y x || rcap lb ub x 
*------------- end example -------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this clarifies the issue,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index