Lars Korsholm
> I have a simulation study where for each value of mu I have 1000
> estimates. Mu runs from .01 to .31
> The "true" value depends on mu.
> its farly easy to plot the median or any other
> egen-statstics versus mu.
> BUT I would like to plot the median _with_ the associated confidense
> interval from -centile- (anything better?)
>
> With a -foreach x=1/31 {- loop this i possible
> since the values of mu is "nice"
> But can it be done smarter/easier/more general?
>
> my code reads:
>
> gen bias=est-true
> gen double cen=.
> gen double up=.
> gen double do=.
> forvalues x = 1/31 {
> qui centile bias if mu==`x'/100
> replace cen=`r(c_1)' if mu==`x'/100
> replace up=`r(ub_1)' if mu==`x'/100
> replace do=`r(lb_1)' if mu==`x'/100
> }
>
> bysort mu: keep if _n==1
> gr cen up do mu, c(.||) s(x..) sa(gr1, replace)
>
I would advise caution with any selection based on
... if <varname> == <real>
for reasons documented at [U] 16.10 and elsewhere.
You are presumably collapsing your data
to avoid precisely the same data points being
plotted again and again. Another way to avoid
this is through -egen, tag()-:
egen tag = tag(mu)
gra ... if tag
Nick
[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/