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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: Determining the 95% CI of the difference in medians using bootstrapping - is this code correct?


From   Philip Jones <pjones8@uwo.ca>
To   statalist@hsphsun2.harvard.edu
Subject   st: Determining the 95% CI of the difference in medians using bootstrapping - is this code correct?
Date   Mon, 19 Sep 2011 07:15:16 -0400

Hi all,

I am using bootstrapping to estimate the 95% CI of the difference in medians in a right-skewed continuous variable (time-to-insertion, or 'tti').

I would appreciate any comments on the following code that (I think!) computes the 95% CI of the difference in medians of the two groups in the study. The code obtains the median of each of the two groups in my dataset, computes the difference between medians, and then runs 1000 repetitions on the code in order to obtain a Normal-based 95% CI of the difference in medians.

 program mydifference, rclass
          version 11
          quietly summarize tti if group==1, detail
          local tti_group1 = r(p50)
          quietly summarize tti if group==2, detail
          local tti_group2 = r(p50)
          return scalar difference = `tti_group1'-`tti_group2'
  end

bootstrap r(difference), rep(1000): mydifference

Many thanks for any comments about whether or not I am doing what I think I am doing.

Phil
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index