Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Empirical cdf with confidence interval


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Empirical cdf with confidence interval
Date   Mon, 25 Mar 2013 16:20:28 -0400

Victoria Sevcenko <vsevcenko.phd2012@london.edu>:

Maybe something like these pointwise CI?

webuse hsng, clear
qui forv r=1/4 {
 g p`r'=.
 g l`r'=.
 g u`r'=.
 replace p`r'=0 in 14
 replace p`r'=1 in 29
 la var p`r' "`:lab (reg) `r''"
 }
g x=_n*1000 in 14/29
la var x "`:var l faminc'"
svyset, srs
qui forv i=15/28 {
 g d=faminc<=`i'*1000
 svy:tab reg d, row ci
 mat b=e(b)
 mat v=e(V)
 forv r=1/4 {
loc l=`r'*2
loc p invlogit(logit(b[1,`l'])
loc s invttail(e(df_r),.025)*sqrt(v[`l',`l'])/b[1,`l']/(1-b[1,`l']))
if b[1,`l']>0 & b[1,`l']<1 {
 replace p`r'=b[1,`l'] in `i'
 replace l`r'=`p'-`s' in `i'
 replace u`r'=`p'+`s' in `i'
 }
  }
 drop d
 }
line p? x
tw rarea u1 l1 x,col(gs14)||line p1 x, clp(l) name(c1, replace) ti(NE) leg(off)
tw rarea u2 l2 x,col(gs14)||line p2 x, clp(l) name(c2, replace) ti(MW) leg(off)
tw rarea u3 l3 x,col(gs14)||line p3 x, clp(l) name(c3, replace) ti(S) leg(off)
tw rarea u4 l4 x,col(gs14)||line p4 x, clp(l) name(c4, replace) ti(W) leg(off)
gr combine c1 c2 c3 c4, nocop

webuse nhanes2, clear
qui forv r=1/4 {
 g p`r'=.
 g l`r'=.
 g u`r'=.
 replace p`r'=0 in 14
 replace p`r'=1 in 29
 la var p`r' "`:lab (region) `r''"
 }
g x=_n in 13/61
la var x "`:var l bmi'"
qui forv i=13/61 {
 g d=bmi<=`i'
 svy:tab region d, row ci
 mat b=e(b)
 mat v=e(V)
 forv r=1/4 {
loc l=`r'*2
loc p invlogit(logit(b[1,`l'])
loc s invttail(e(df_r),.025)*sqrt(v[`l',`l'])/b[1,`l']/(1-b[1,`l']))
if b[1,`l']>0 & b[1,`l']<1 {
 replace p`r'=b[1,`l'] in `i'
 replace l`r'=`p'-`s' in `i'
 replace u`r'=`p'+`s' in `i'
 }
  }
 drop d
 }
line p? x
tw rarea u1 l1 x,col(gs14)||line p1 x, clp(l) name(c1, replace) ti(NE) leg(off)
tw rarea u2 l2 x,col(gs14)||line p2 x, clp(l) name(c2, replace) ti(MW) leg(off)
tw rarea u3 l3 x,col(gs14)||line p3 x, clp(l) name(c3, replace) ti(S) leg(off)
tw rarea u4 l4 x,col(gs14)||line p4 x, clp(l) name(c4, replace) ti(W) leg(off)
gr combine c1 c2 c3 c4, nocop


On Mon, Mar 25, 2013 at 6:47 AM, Victoria Sevcenko
<vsevcenko.phd2012@london.edu> wrote:
> I would like to plot, for various population sub-groups on the same graph, empirical cdfs with their associated confidence intervals. Is there any command in stata that can do this?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index