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

st: simulating uniform entry times

From   Friederike Barthel <>
To   "''" <>
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

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))

set seed 59382

program drop sampsim dosampsim

Thank you for your help!

Sophie Barthel
*   For searches and help try:

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