Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Question about Baseline Hazard in Parametric Hazard Models
From
Steven Samuels <[email protected]>
To
[email protected]
Subject
Re: st: Question about Baseline Hazard in Parametric Hazard Models
Date
Tue, 9 Nov 2010 17:51:35 -0500
Very nice, Paul! This use of -stsplit- to fit a parametric hazard
model is a neat trick that I hadn't seen before. One component of the
log-likelihood for a parametric model is the integral of the hazard
h(t). When h(t) is a polynomial in t of degree>2, the integral has no
closed form (as far as I know). After -stsplit-, the log-likelihood
for -streg- is numerical approximation to that integral. It works
fairly well for this example, with just two failure free intervals of
5 months and one of 6 months. The approximation might be better with
more splits, especially for data with a lower density of events. That
is what I would recommend to TS, the original poster.
Steve
****CODE BEGINS *****
// Split at failures
sysuse cancer, clear
gen id=_n
stset studytime, failure(died) id(id)
stsplit, at(failures)
orthpoly _t, gen(t*) degree(3)
streg t*, dist(exp)
predict hp1, hazard
label var hp1 "stsplit at failures"
scatter hp1 _t, saving(hp1, replace) nodraw
// Split at single months
sysuse cancer, clear
gen id=_n
stset studytime, failure(died) id(id)
stsplit single, at(1(1)39)
orthpoly _t, gen(t*) degree(3)
streg t*, dist(exp)
predict hp2, hazard
label var hp2 "split at single months-"
scatter hp2 _t, saving(hp2, replace) nodraw
graph combine hp1.gph hp2.gph, ycommon xcommon
**CODE ENDS*******
Steve
On Nov 9, 2010, at 9:21 AM, Lambert, Paul C. (Dr.) wrote:
*
I think Maarten needs to add an -stsplit- to his code before
generating the polynomals, i.e.
sysuse cancer, clear
gen id = _n
stset studytime, failure(died) id(id)
stsplit, at(failures)
orthpoly _t, gen(t*) degree(3)
streg t*, dist(exp)
However, I agree with both Maarten and Steve that polynomials are not
a good way to model the hazard function. Restricted cubic splines are
a useful alternative and you could calulate splines rather than
polynomials in the above example. However, fitting a model after using
-stsplit, at(failures)- on a large data set becomes paintfully slow.
If you want to use splines and not have to use -stsplit- then you can
use -stpm2- (available from SSC), which models on the log cumulative
hazard scale. Below is an example of estimating a hazard function
which has a turning point using a restriced cubic splines with 4 knots
(3 df).
clear
webuse brcancer
stset rectime, f(censrec=1) scale(365.25) exit(time 5*365.25) id(id)
stpm2, scale(hazard) df(3)
predict h, hazard ci
twoway (rarea h_lci h_uci _t, sort pstyle(ci)) (line h _t, sort)
Paul
Dr Paul C Lambert
Reader in Medical Statistics
Centre for Biostatistics & Genetic Epidemiology
Department of Health Sciences
University of Leicester
2nd Floor, Adrian Building
University Road
Leicester LE1 7RH
Tel: +44 (0)116 229 7265, Fax: +44 (0)116 229 7250
e-mail: [email protected]
Homepage: http://www2.le.ac.uk/Members/pl4/
________________________________________
From: [email protected] [[email protected]
] On Behalf Of Wei-Kang Shih [[email protected]]
Sent: Tuesday, November 09, 2010 1:46 PM
To: [email protected]
Subject: Re: st: Question about Baseline Hazard in Parametric Hazard
Models
Marrten and Steven,
Thank you both for your suggestions. And yes, the reason I want to
impose a third polynomial baseline hazard is to reproduce some work
done by others. I will try both your suggestion to see what I can get.
Thanks so much again.
TS
On Tue, Nov 9, 2010 at 3:29 AM, Maarten buis <[email protected]>
wrote:
--- On Nov 8, 2010, at 5:33 PM, Irwin T.S. Wang wrote:
I would like to specify/estimate a baseline hazard
function, which is not among the distribution provided
by Stata, e.g. exponential, Gompertz, in a Proportional
Hazard (PH) models. For example, I want to restrict the
shape of the the baseline hazard to a third degree
polynomial in time
--- On Tue, 9/11/10, Steven Samuels wrote:
Two suggestions: 1) -stpm2- from SSC, which uses
restricted cubic splines; and 2) -stcox-, followed by
-stcurve-, which will smooth the Cox baseline hazard. I
recommend against third degree polynomials, because they can
curve up or down at the ends unpredictably and implausibly.
Another option you could investigate is a piecewise constant
model, see -ssc d stpiece-.
I agree with Steven that such a polynomial would often impose
too much unrealistic structure on your baseline hazard. The
only reason I can imagine why you would want use the cubic
polynomial baseline hazard would be when you want to reproduce
an analysis made by someone else who used that baseline hazard
(typically to follow that with a "better" analysis to show
that they were wrong...). If that is what you want to do, then
below is an example of how to do that (I used -orthpoly- to
avoid problems with colinearity):
*-------- begin example ---------
sysuse cancer, clear
stset studytime, failure(died)
orthpoly _t, gen(t*) degree(3)
streg t*, dist(exp)
*--------- end example ----------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* 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/
*
* 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/