Bookmark and Share

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]

Re: st: Estimating the hazard function


From   Steven Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Estimating the hazard function
Date   Sun, 11 Sep 2011 13:26:47 -0400

Just to add.  -stcurve- works only after -stcox- and -streg-. To get the smoothed hazard based on the Kaplan-Meier estimate:

1) run -stcox- with a single dummy predictor and the default (Breslow-Day) estimator of the baseline survival curve. The resulting estimate is identical to the K-M estimate.
2) run -stcurve- as below.  


Steve


I was wrong about -kdensity-; and, apparently, Stata doesn't have a built-in kernel smoother.  But then I noticed that -stcurve- has an "outfile()" option for saving the estimated smooths.  Notice that -stcurve- actually plots the log estimated hazards. 

Steve

*************CODE BEGINS*************
set more off
webuse drugtr
stcox age drug
stcurve, hazard kernel(gauss) yscale(log) outfile(new, replace)  saving(g01, replace) ylabel(.02 .04 .06 .08 .10 .12)
use new, clear
twoway scatter  haz1 _t, c(l) msymbol(i) yscale(log) ///
 ti("Saved Smooths") ///
saving(g02, replace)  
graph combine g01 g02
***************************************************


On Sep 10, 2011, at 8:04 PM, Brendan Corcoran wrote:

Thanks Steven.

How do I actually incorporate the hazard contributions into -kdensity-?

The analysis time variable is _t, and I've generated the hazard
contributions through running -sts gen H=h-

Just unsure how to apply -kdensity- to _t while also using the hazard
contributions -H- to weight it somehow.


On Sat, Sep 10, 2011 at 10:26 PM, Steven Samuels <sjsamuels@gmail.com> wrote:
> 
> You can use -kdensity- to estimate the hazard function and, as in -stcurve-,  set the smoothing options yourself. The difference is that -kdensity- has an option to generate the smoothed estimates.
> 
> Steve
> On Sep 1
> 
> 0, 2011, at 3:10 PM, Brendan Corcoran wrote:
> 
> I want to get a hold of the data produced by -sts graph, hazard-  i.e.
> the h(t) estimated at each time point.  This is so I can produce
> hazard graphs in other applications.
> 
> I understand that -sts gen dh=h- produces the estimated hazard
> component deltaH_j = H(t_j) - H(t_(j-1)), and that to calculate h(t)
> -sts graph, hazard- calculates a weighted kernel-density estimate
> using deltaH_j.
> 
> But how could I get the actual h(t) values calculated here, or as a
> second option how could I run the weighted kernel-density estimate
> myself?
> 
> 
> *
> *   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/
> 

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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index