The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Weighting data » weighted median
weighted median [message #518] Fri, 07 June 2013 03:55 Go to next message
isde is currently offline  isde
Messages: 2
Registered: June 2013
Member
Hello.
I writing because I cannot find my way out of this apparently trivial calculation: I have to estimate the median for age at different vaccinations in several countries with Children recodes datasets, separately. I'm working on STATA10.
I'm trying to get weighted medians.
I've done "gen wgt=v005/1000000" and "sum var [iw=wgt]".The command "iweight" is not allowed with "sum,d". How can I do?
Do I have to use svyset, in which case what are the variable to incude (PSU is v021? stratification variables are v025? v024? both?).
That would be great if you could provide me with some answers. Thanks a lot in advance.
Re: weighted median [message #520 is a reply to message #518] Fri, 07 June 2013 12:37 Go to previous messageGo to next message
Reduced-For(u)m
Messages: 292
Registered: March 2013
Senior Member

Use pweight. These are probably weights. The stratification stuff should only matter for standard errors. If you want those, you could use quantile regression for the median, unconditional on anything (so just svy: qreg Y). I think qreg works with svy:, but I'm not totally positive.
Re: weighted median [message #531 is a reply to message #520] Mon, 10 June 2013 09:09 Go to previous messageGo to next message
isde is currently offline  isde
Messages: 2
Registered: June 2013
Member
Thank you very much for your answer.
I just tried your options. Unfortunatly, pweight does not work better than iweight, and qreg is not supported by svy.
I'm still stuck...
Re: weighted median [message #532 is a reply to message #531] Mon, 10 June 2013 14:00 Go to previous messageGo to next message
Reduced-For(u)m
Messages: 292
Registered: March 2013
Senior Member

Ugh. That is embarrassing that I didn't remember that summarize doesn't take p-weights. My bad.

How about collapse: http://www.stata.com/help.cgi?collapse#weight

collapse (median) VacAge [pweight=weight]

If the countries are appended together, you could add " , by(country)".

This one should work.
Re: weighted median [message #594 is a reply to message #532] Wed, 03 July 2013 18:21 Go to previous messageGo to next message
bsayer
Messages: 12
Registered: March 2013
Location: Silver Spring Maryland
Member
If you have the option of using SUDAAN, it does weighted percentiles, including variances.

Bryan Sayer
Statistician
Social & Scientific Systems, Inc.
Re: weighted median [message #595 is a reply to message #594] Wed, 03 July 2013 18:22 Go to previous message
bsayer
Messages: 12
Registered: March 2013
Location: Silver Spring Maryland
Member
Also, you can calculate them by brute force, sorting by weight and creating the running sum of the weight, then finding the percentile points you want.

Bryan Sayer
Statistician
Social & Scientific Systems, Inc.
Previous Topic: Domestic Violence Weighting
Next Topic: weighting combined datasets
Goto Forum:
  


Current Time: Fri Mar 29 08:23:13 Coordinated Universal Time 2024