Statalist


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

RE: st: RE: AW: customising ranges of the axis in Kaplan Meier plot


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: AW: customising ranges of the axis in Kaplan Meier plot
Date   Wed, 7 Oct 2009 15:53:01 +0100

I don't see any reason why using -separate- as compared with generating
separate variables yourself should mean anything different in ensuing
graphs. The result is the same, a bunch of disjoint variables. 

Nick 
[email protected] 

[email protected]

This question has been before on statalist, and a google search
(statalist restrict range kaplan-meier) would have found an answer
(e.g. http://www.stata.com/statalist/archive/2005-03/msg00229.html)

The ordinary graph axis commands don't work with -sts graph-. The only
way  to restrict the axes is to  generate the points for the CDF with
-sts- gen (see below) and plot them with -twoway-.   I use -levelsof-
below.  Nick Cox pointed out that -separate-  should do essentially
the same thing, but I've observed that the plot connections look
different.  To make the graph look nice you might have to augment the
data for each group with a fake point at (0,0), since zero times are
not  allowed in -sts- .

-Steve


*******************************************
sts gen surv = s, by(factor)
gen cdf =100*(1-surv)

****************************************************
* Create a separate CDF for each factor level
****************************************************
sort factor outcome
levelsof factor, local(fac_lev)
foreach i of local fac_lev {
gen ydf`i' = cdf if factor==`i'
}

twoway scatter ydf* outcome  if  cdf<= 0.5,
connect(J J....)

**************************************************


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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