Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: simulating uniform entry times


From   Friederike Barthel <FriederikeB@ctu.mrc.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: simulating uniform entry times
Date   Fri, 11 Apr 2003 10:52:12 +0100

Dear List

I am trying to simulate data from two exponential distributions with a
certain hazard ratio in order to simulate a clinical trial. The code for
that part is working fine.

However, I want to now let the subjects enter using uniform entry rates over
a period of T years. Does anyone have any hints on how to do this?

Posted below is the simulation program as it stands without uniform entry:

capture program drop sampsim

program define sampsim
	postfile samp chi2 using sampres, replace
	forvalues i=1/1000 {
		quietly dosampsim
	}
	postclose samp
end

capture program drop dosampsim

program define dosampsim
	drop _all
	set obs 16
	gen byte group = _n<=(_N/2)
	gen  x=-log(uniform()) if group==0
	replace x=-(1/3.5)*log(uniform()) if group==1
	stset x
	sts test group
	post samp (r(chi2))
end

set seed 59382
sampsim

program drop sampsim dosampsim
exit


Thank you for your help!

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



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