Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Tim Evans <Tim.Evans@wmciu.nhs.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: How to overlay four Cox survival curves in one graph |

Date |
Fri, 19 Apr 2013 09:56:07 +0100 |

Agnes, This might not be the most eloquent option, but this is how I thought you might combine your two models onto one graph (mostly borrowed from http://www.stata.com/statalist/archive/2004-04/msg00139.html - there are more examples on this thread): clear sysuse cancer drop if drug==3 qui stset st,failure(di) sum age gen meanage=age-r(mean) stcox drug, basesurv(baseline_drug) strata(drug) nolog gen s1=baseline_drug if drug==1 label var s1 "Placebo" gen s2=baseline_drug if drug==2 label var s2 "Drug X" stcox meanage, basesurv(baseline_age) strata(drug) nolog gen s3=baseline_age if drug==1 label var s3 "Placebo_1" gen s4=baseline_age if drug==2 label var s4 "Drug X_1" sort _t twoway line s1 _t, connect(stairstep) || /* */ line s2 _t, connect(stairstep) || /* */ line s3 _t, connect(stairstep) || /* */ line s4 _t, connect(stairstep) ||, /* */ legend(rows(1)) title("Survival at average age")/* */ xtitle("analysis time") Best wishes Tim -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 19 April 2013 01:06 To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: How to overlay four Cox survival curves in one graph Tim gave an explanation. Looking at the help gives you more detail: basesurv(newvar) adds newvar to the data containing the estimated baseline survivor function. In the null model, this is equivalent to the Kaplan-Meier product-limit estimate. If strata() is also specified, baseline estimates for each stratum are provided. So you need to run each model separately with -basesurv()- as an option. Then you can plot those variables on a -line- plot. You'll need to work on the -legend()- as -basesurv()- attaches the same variable label. Nick njcoxstata@gmail.com On 19 April 2013 00:09, agnes cheah <agnesxie4@gmail.com> wrote: > Thanks Tim and Nick. However, I am not sure which words I need to > replace with variable names or commands to draw the 4 curves in one > graph. Do I have to save the graphs into memory and call in out again > later? > Just to put it in context, I used these commands to plot Cox survival > curves each time after performing the stcox regression stcurve, > survival at 1(group=0 at 2(group=1)- plotted two lines based on group > stcurve, survival at 1(Drug=1) at 2(Drug=2)- plotted two lines based > on Drug On Thu, Apr 18, 2013 at 8:04 PM, Nick Cox <njcoxstata@gmail.com> wrote: >> This should work too, in the same example. >> >> line basesurvest* _t, connect(J ..) sort legend(order(1 "1" 2 "2" 3 >> "3")) On 18 April 2013 10:58, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote: >>> Can you run -stcox- with and estimate the basesurv. You should then be able to construct your survival curves in one graph using something like this: >>> >>> forval i = 1/3 { >>> stcox if whatever==`i', estimate basesurv(basesurvest`i') } >>> >>> line basesurvest1 _t, connect(J) sort || /* */ line basesurvest2 _t, >>> connect(J) sort || /* */ line basesurvest3 _t, connect(J) sort >> >> agnes cheah >> >>> I have plotted two separate Cox survival curves (corresponding to two Cox models). How do I overlay the two plots (containing 2 curves, because stcurve, by variable command used) into one single graph)? I tried graph combine (not what I want) and addplot (does not seem to work). * * 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/ _DISCLAIMER: This email and any files transmitted with it are confidential. If you are not the intended recipient, any reading, printing, storage, disclosure, copying or any other action taken in respect of this e-mail is prohibited and may be unlawful. If you are not the intended recipient, please notify the sender immediately by using the reply function and then permanently delete what you have received. The information contained in this e-mail may be subject to public disclosure under the Freedom of Information Act 2000. The confidentiality of this e-mail and your reply cannot be guaranteed, unless the information is legally exempt from disclosure. * * 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/

**References**:**st: RE: How to overlay four Cox survival curves in one graph***From:*Tim Evans <Tim.Evans@wmciu.nhs.uk>

**Re: st: RE: How to overlay four Cox survival curves in one graph***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: RE: How to overlay four Cox survival curves in one graph***From:*agnes cheah <agnesxie4@gmail.com>

- Prev by Date:
**Re: st: Interaction terms when one variable is omitted - query** - Next by Date:
**st: Nearstat competitor count** - Previous by thread:
**Re: st: RE: How to overlay four Cox survival curves in one graph** - Next by thread:
**st: Graphing odds ratios** - Index(es):