Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: confidence interval for median


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: confidence interval for median
Date   Tue, 12 Aug 2008 14:08:00 +0100

How does this differ from the (also recommended in this thread) use of
-centile-? 

Nick 
[email protected] 

Joseph Coveney

moleps islon wrote:

I need to find the confidence interval for my me[di]an. I thought to use
a
jackknife command, but I cant get it to work: Jknife: sum age. Can
someone help me out?

------------------------------------------------------------------------
--------

Others have suggested bootstrapping, but you can find R code for the
so-called exact nonparametric confidence interval for the median at
https://stat.ethz.ch/pipermail/r-help/2007-April/129910.html .

It's straightforward (think: inverse -signtest-); the hardest part is
deciding upon a Stata equivalent to R's qbinom(c(0025, 0.975, n, 0.5).
I'd
recommend using -cii , exact- and going from there with the returned
scalars, but others on the list might recommend better alternatives.

The bootstrap and exact nonparametric CIs happen to agree in the example
below, but if the words "exact" and "nonparametric" conjure up others
like
"reduced efficiency", then you can assuage yourself with a comparison of
coverage using -simulate-.

clear *
set more off
sysuse auto
cii `=_N' 0.5, exact
local LCL_n = floor(r(lb) * _N) + 1
local UCL_n = floor(r(ub) * _N) + 1
sort mpg
display mpg[`LCL_n'], mpg[`UCL_n']
quietly bootstrap r(p50), reps(400) ///
  seed(`=date("2008-08-12", "YMD")'): summarize mpg, detail
estat bootstrap, percentile
exit

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index