Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to draw a smoothed hazard curve with graph twoway


From   Svend Juul <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to draw a smoothed hazard curve with graph twoway
Date   Sat, 3 May 2008 15:39:37 +0200

Marjo Pyy-Martikainen wrote: 
 
how can I reproduce a smoothed hazard curve plotted by stcurve after a Cox ph
model with graph twoway (my aim is to overlay two smoothed hazard curves based on two different data sets so I think I need to use the graph twoway command at least for one of the hazard curves)?. I cannot figure out how the smoothing done by stcurve can be replicated with graph twoway.  Can someone please give me a hint
how to modify the code below?
 
stcox <covariates>, basehc(h)
stcurve, hazard width(1)
graph twoway (line h _t, sort)
 
==============================================================
 
You can use -stcurve-s -outfile()- option. Illustration:
 
      webuse drugtr.dta , clear
      stcox age if drug==0 , basehc(h0)
      stcurve , hazard width(1) outfile(drug0.dta, replace)
      use drug0.dta , clear
      rename haz1 haz0
      save , replace
 
      webuse drugtr.dta , clear
      stcox age if drug==1 , basehc(h1)
      stcurve , hazard width(1) outfile(drug1.dta, replace)
      use drug1.dta , clear
      append using drug0.dta
 
      twoway (line haz0 haz1 _t, sort)
 
Hope this helps
Svend
________________________________________________________ 
 
Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:   +45 8942 6090 
Phone, home:   +45 8693 7796 
Fax:           +45 8613 1580 
E-mail:        sj@soci.au.dk 
_________________________________________________________ 

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