Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: difference in medians . Raw vs calculated


From   Richard Hiscock <[email protected]>
To   [email protected]
Subject   st: difference in medians . Raw vs calculated
Date   Sun, 20 Jan 2013 12:00:07 +1100

I wish to derive 95%CI for difference in medians and noticed that difference in raw median values between groups didn't equal that calculated using packages cendif (R.Newson) and cid (P.Royston) Clearly Im missing something and would be grateful for an explanation.

I suspect it relates to a transformation performed prior to calculation of the difference & subsequent back transformation to original units.

However it is hard to present raw unit median values and the the difference in medians (& CI) which are not the same. In my data set (plasma protein assay) the raw difference in medians is 0.5 whereas the difference calculated by cid or cendif is 0.33 making it hard to explain to readers.

Thanks for any advice



Illustrated using the auto data set:



Use auto

tabstat weight, by(foreign) stats(p50)



Summary for variables: weight by categories of: foreign (Car type)



foreign |       p50

---------+----------

Domestic |      3360

Foreign |      2180

---------+----------

  Total |      3190

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



*difference = 1180





. cendif weight, by(foreign)

Y-variable: weight (Weight (lbs.))

Grouped by: foreign (Car type)

Group numbers:



  Car type |      Freq.     Percent        Cum.

------------+-----------------------------------

  Domestic |         52       70.27       70.27

   Foreign |         22       29.73      100.00

------------+-----------------------------------

     Total |         74      100.00

Transformation: Fisher's z

95% confidence interval(s) for percentile difference(s)

between values of weight in first and second groups:

  Percent    Pctl_Dif     Minimum     Maximum

       50        1095         750        1330



. cid weight,by(foreign) unpaired



Normal-based confidence interval for difference in  means by foreign



Variable |     Obs     Estimate    Std. Err.       [95% Conf. Interval]

---------+-------------------------------------------------------------

 weight |      74     1001.206    160.2876        681.6788    1320.734



. qreg weight foreign

Iteration  1:  WLS sum of weighted deviations =  34840.693



Iteration  1: sum of abs. weighted deviations =      34860

note:  alternate solutions exist

Iteration  2: sum of abs. weighted deviations =      34620

note:  alternate solutions exist

Iteration  3: sum of abs. weighted deviations =      34580



Median regression                                    Number of obs =        74

 Raw sum of deviations    48860 (about 3180)

 Min sum of deviations    34580                     Pseudo R2     =    0.2923



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

     weight |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]

-------------+----------------------------------------------------------------

    foreign |      -1150   223.2969    -5.15   0.000    -1595.134   -704.8659

      _cons |       3350   121.7526    27.51   0.000     3107.291    3592.709

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



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index