[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"E. Paul Wileyto" <epw@mail.med.upenn.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: simulation of survival datasets in Stata |

Date |
Mon, 10 Mar 2008 08:20:48 -0400 |

You need to simulate time-to-event followed by censoring. The easiest is exponential or Weibull.

Weibull is :

S=exp(-lambda*t^p)

where lambda is the hazard ratio:

lambda=exp(sum beta x)

beta_0 is a constant reflecting the baseline hazard. beta_1 ... reflect the effects of covariates.

p is the Weibull shape parameter (positive number), and if valued p=1 reduces to exponential.

Generate lambda with hazard ratio 1.9 for drug treatment (0,1):

- lambda=-2.5+ln(1.9)*drug -

To simulate time-to-event, substitute the random unit variate R for S, and solve for t.

t=(-ln(R)/lambda)^(1/p)

or in Stata:

- gen t=(-ln(uniform())/lambda)^(1/p) -

Some of the t values will be very large, and you will need a censoring variable to reflect the end of study (say 90 days).

- gen fail=1 -

- replace fail=0 if t>90 -

- replace t=90 if t>90 -

Then, look at your handiwork-

- stset t, fail(fail) -

- sts graph, by(drug) -

- stcox drug -

Paul

Michael McCulloch wrote:

Hello Statalist members,--

I'm seeking examples of simulation of survival datasets in Stata. Can anyone point me in the right direction? My goal is to simulate a dataset to validate a Stata survival program I've written.

Thank you.

E. Paul Wileyto, Ph.D.

Assistant Professor of Biostatistics

Tobacco Use Research Center

School of Medicine, U. of Pennsylvania

3535 Market Street, Suite 4100

Philadelphia, PA 19104-3309

215-746-7147

Fax: 215-746-7140

epw@mail.med.upenn.edu

http://mail.med.upenn.edu/~epw/

*

* For searches and help try:

* http://www.stata.com/support/faqs/res/findit.html

* http://www.stata.com/support/statalist/faq

* http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: simulation of survival datasets in Stata***From:*Michael McCulloch <mm@pinest.org>

**Re: st: simulation of survival datasets in Stata***From:*Enzo Coviello <enzo.coviello@alice.it>

**References**:**st: simulation of survival datasets in Stata***From:*Michael McCulloch <mm@pinest.org>

- Prev by Date:
**Re: st: adding -input- in an ado file** - Next by Date:
**st: RE: Testing for Spatial Autocorrelation in Residuals** - Previous by thread:
**RE: st: histogram with normal distribution modified** - Next by thread:
**Re: st: simulation of survival datasets in Stata** - Index(es):

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