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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Recovering the discrete time (interval) baseline hazard function


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Recovering the discrete time (interval) baseline hazard function
Date   Wed, 27 Apr 2011 08:27:08 +0100 (BST)

--- On Wed, 27/4/11, Urmi Bhattacharya wrote:
> I am interested in plotting the discrete time (interval)
> baseline hazard function against the discrete failure time.

-cloglog- models the log(hazard) so to get the baseline hazard
you need to exponentiate the variable you generated. However,
I would use -adjust- for that. That safes you typing (and thus
reduces the number of opportunities of making a typo) and it
also allows you to predict confidence intervals. I added an
example below:

*---------------------- begin example ----------------------
sysuse cancer, clear
gen id = _n

expand studytime
bysort id : gen month = _n

// the addition (month) makes sure that _n==_N means
// the last month for that individual
bysort id (month) : gen byte dead = died==1 & _n==_N
lab var dead "binary depvar for discrete hazard model"

// further trick to safe you some typing
gen halfyr = ceil(month/6)
ta halfyr ,ge(dur)
replace dur6 = dur6 + dur7
drop dur7 halfyr

// when looking at the baseline hazard you need to make
// sure it refers to a meaningful group by making sure
// that the value 0 for all your explanatory variables 
// refer to a meaningful value within the range of the
// data, here I centered age at 50 years.
gen c_age = age - 50

cloglog dead drug c_age dur1 dur2 dur3 dur4 dur5 dur6, ///
        nocons nolog

// use -adjust- to predict baseline hazard and its
// confidence interval
preserve
adjust drug=0 c_age=0, by(month) exp ci replace
sort month
twoway rarea lb ub month ||    ///
       line exp month,         ///
       legend(off)             ///
       ytitle(baseline hazard)
restore
*-------------------- 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index