Bookmark and Share

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: Issue with hazard function generated by sts graph


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Issue with hazard function generated by sts graph
Date   Wed, 7 Mar 2012 13:28:31 -0500

Masashi Miyairi:

I want to correct part of my earlier earlier comment. 

The left-hand part of your plot was probably not especially noisy. If you had looked at the actual values, you would probably have seen that they are quite close to what is expected. In experiments with several seeds, the smoothed hazard from  t= 0- 20 ranged  from 0.17-0.22, which is within ±0.03 of lambda = 0.20.  

Setting tmax(20) made such trivial differences _look_ big, because the y scale was restricted. Removing the tmax(20) would have shown you that the early part of the hazard was quite constant in comparison to the noisy right hand part of the graph.  Reducing the kernel bandwidth (width()) option, might also have reduced the smoothing artifacts.

Note: if you report unusual phenomena with random numbers, be sure to -set seed- first  and tell us what it is. Otherwise nobody, including you, can replicate exactly what you first saw.

Steve
[email protected]




On Mar 6, 2012, at 12:10 PM, Steve Samuels wrote:


There's nothing strange here. You have a noisy graph, and you've focused only on a small part of it.  Remove the tmax(20) option to see the entire plot.  Set seed for reproducibility. The diagnostic for an exponential function with hazard = 1/5 is a cumulative hazard function in the form of a straight line, with a slope of 1/5. That's what you will see if you:

********************
sts graph, cumhaz
********************


Steve

On Mar 5, 2012, at 11:30 PM, Masashi Miyairi wrote:

Hi everyone,

I see something strange when plotting hazard rates by "sts graph, hazard". For example,  when I apply the command to a set of simulated exponential random variables, I get a graph that has a upward sloping part in the very beginning. In theory, this shouldn't be the case because exponential random variables have constant hazards, so the graph shouldn't have a increasing pattern. I am wondering if this issue has been documented, or I am missing something using this command. The following is the code that generates my puzzle.

set obs 5000
* Generate exponential random variables
gen dur = -5*log( uniform() )
* Plot the hazard rates
stset dur
sts graph, hazard tmax(20)

Thank you,
Masashi Miyairi
Department of Economics
University of Western Ontario





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