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]
Re: st: cumul, relrank and pweights
From
Steve Samuels <[email protected]>
To
[email protected]
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'
/* Add 0-0 point */
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
[email protected]
> On Feb 19, 2014, at 3:34 PM, Olga Gorbachev <[email protected]> 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/