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

*   For searches and help try:

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