Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: confidence intervals around point estimates plotted against time ascategorical variable


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: confidence intervals around point estimates plotted against time ascategorical variable
Date   Sun, 8 May 2005 22:30:59 +0100

Svend Juul
 
> Richard Lenhardt wants to plot, with confidence intervals, 
> the proportion drug users for each month. To proceed I 
> created an artificial dataset with 30% users:
>  
> clear
> set seed 12345
> set obs 1000
> gen x=0
> replace x=1 if uniform()<0.3
> gen month=1+int(12*uniform())
> 
> -ci x, binomial- calculates proportion and confidence limits 
> for each month. -ci- saves r(mean), r(lb) and r(ub), and 
> -statsby- lets you include these results in a new dataset (test1):
>  
> statsby "ci x, binomial" r(mean) r(lb) r(ub), by(month) 
> saving(test1) replace
> use test1 , clear
> rename _stat_1 prop
> rename _stat_2 lb
> rename _stat_3 ub
> twoway (line prop month)(rcap lb ub month)
> Is that what you wanted.
>  
> Actually Nick Cox made -ciplot-, to be downloaded by:
>   ssc install ciplot
>  
> -ciplot- does much of the same, but the first method gives you
> more freedom when designing the graph, I think.

I agree with Svend. If you create your own resultsset, 
you have more flexibility over appearance. The purpose
of -ciplot- is just to provide a quick-and-not-too-dirty 
plot. 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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