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   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: confidence intervals around point estimates plotted against time ascategorical variable
Date   Sat, 7 May 2005 17:47:07 +0200

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.
 
Hope you can use this.

Svend
 
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 
E-mail:       [email protected] 
_________________________________________________________ 
 

*
*   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