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

Re: st: confidence interval for median

From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   Re: st: confidence interval for median
Date   Tue, 12 Aug 2008 21:55:09 +0900

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 .

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

Joseph Coveney

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

*   For searches and help try:

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