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 on April 23, and its replacement, is already up and running.

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

RE: st: How to find weighted median_st-svyself-problem_solved

From   "Reda, Ayalu (Alumni)" <>
To   "" <>
Subject   RE: st: How to find weighted median_st-svyself-problem_solved
Date   Tue, 5 Feb 2013 05:27:25 +0100

Dear Steve,
Thank you so much for your quick response!
I just figured out the problem.

From: [] On Behalf Of Steve Samuels []
Sent: Tuesday, February 05, 2013 7:11 AM
Subject: Re: st: How to find weighted median_st-svy

The FAQ ask that you demonstrate a claimed problem (show the results), preferably with an accessible data set. With the "page2" data,  I've found no differences in the weighted medians estimated by  -stsum-,  -stdes-, and  -sts graph- .

*************CODE BEGINS*************
webuse page2,clear
set seed 46392
gen pwt = runiform()*100
stset  time [pw =pwt], fail(dead)
stdes, weight
sts graph, yline(50) xline(233)
**************CODE ENDS**************


Steven J. Samuels
Consulting Statistician
18 Cantine's Island
Saugerties NY 12477 USA
Voice: 845-246-0774

On Feb 4, 2013, at 9:44 PM, Reda, Ayalu (Alumni) wrote:


I was analyzing the three DHS survey (2000, 2005, and 2011) data on Ethiopia.

The problem I am experiencing is that Stata wouldn't provide me the weighted medians in stsum. I have also tried the stdescribe command but to no avail. I know that there is a problem in these estimates since the values I am getting from the survival curves and the stsum command are different. Given the data, I also expect that the weighted survival times will be numbers with decimals as opposed to the whole numbers that stdescribe and stsum keep providing me.

I think that the the values in the Kaplan-Meier graph are somehow correctly weighted, where as those of the stdescribe and stsum are not.

Is there anyway other way that I could estimate the weighted medians? If this is not possible is there a wisdom in taking the median values of the K-M curve? If yes, how do I precisely do that?

Many thanks in advance,


Here are the commands I applied:

/*...graph and calculate time to first marriage among women who had premarital sex.*/

svyset psuXyear [pweight=weight], strata(waveXstrata)
stset premsexmar2 [pweight=weight], failure(evermarrie)
stsum, by(source)
sort source
by source: stdescribe
sts graph, by(source) xlabel (1(1)6) tmin(0) tmax(7) xline( 3 6, lpattern(shortdash)) xtitle("risk period") title("Kaplan-Meier survival curves of time to first marriage among women who had premarital sex")

*   For searches and help try:

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index