Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: cumulative distribution function (assigned values)


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: cumulative distribution function (assigned values)
Date   Tue, 3 Jun 2003 13:37:57 +0100

Manuel Kast
 
> how can I generate in Stata 8.0 a new variable which 
> contains the values 
> assigned by the observed cumulative distribution of one 
> variable? In other 
> words, I would like to get those values stored in a new 
> variable, that are 
> used by the command "cdf varname" to plot the sample cumulative 
> distribution function of varname.
> I don't think the command "cumul varname" will not work for 
> my case, since 
> my variable contains several observations with the same 
> values, but "cumul 
> varname" assigns different values to to these, depending 
> how they were 
> initially ordered.

sort varname 
gen cumul = sum(varname < .) 
by varname: replace cumul = cumul[_N] 
replace cumul = cumul / cumul[_N] 

Nick 
n.j.cox@durham.ac.uk 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index