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

# Re: st: cumul, relrank and pweights

 From Steve Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: cumul, relrank and pweights Date Wed, 19 Feb 2014 20:35:50 -0500

```-cumul- with [aw = ] statement and the "equal" option will generate the
probability weighted cdf. This is demonstrated below. I first generate
the probability weighted cdf ("cdf1") by means of Stata's -stset- and -sts
gen- commands, then compare it to the aweighted cdf ("cdf2") generated by
-cumul-. If you want to plot the cdf, then you'll have to add the 0-0
point yourself. I've never heard of -relrank-. Did you perhaps overloook
the request in the FAQ to "Say what commands you are using. If they are
not part of official Stata, say where they came from"?

*************CODE BEGINS*************
sysuse auto, clear
/* Compute using sts gen */
stset mpg [pw = turn]
sts gen surv = s
gen cdf1 = 1 - surv

/* compare to cumul */
cumul mpg [aw = turn], gen(cdf2)  equal
assert cdf1 == cdf2
sum cdf*
tempfile t1
save `t1'

keep in 1
replace mpg = 0 in 1
replace cdf2 = 0 in 1
append using `t1'
sort mpg
twoway connect cdf2 mpg, c(J) msymbol(i)
**************CODE ENDS**************

Steve
sjsamuels@gmail.com

> On Feb 19, 2014, at 3:34 PM, Olga Gorbachev <olga.gorbachev@gmail.com> wrote:
>
> Hell list serve,
>
> I am trying to generate some cdfs for my survey data. I know cumul can
> be combined with aweights and fweights, but can it be combined with
> pweights? and if not, are there other options?
> Similarly, I'd like to know whether relrank can be used with pweights,
> and if not whether there are options that will allow me to use
> pweights.
> I know that _pctile can be used with pweights, so I imagine there is a
> way to "fix" cumul and relrank to do that as well, I am just not the
> best programmer to do it myself.
>

*
*   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/
```