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]

st: Bug in stsplit and stptime - or me ?


From   "Jesper Lindhardsen" <[email protected]>
To   <[email protected]>
Subject   st: Bug in stsplit and stptime - or me ?
Date   Sun, 9 Oct 2011 23:01:32 +0200

Hi All,

This may be a rare problem, however, since the method is used in some
user-written ado-files and at the UCLA stata site, I figured it is worth
to see if others can either correct me or reproduce the problem.

It seems that a new stset using the previous stata generated underscore
variable _t under some circumstances can produce erroneous results.
Specifically -stptime- (but not -strate-) miscalculates risktime, and
thus rates, if the previous -stset- used the enter option, but the new
-stset- uses the origin option. Also, this is the case with -stsplit-
which produces wrong entry and exit times. This seems to be related to
the handling of the _t variable, as renaming/cloning this after the
first -stset- fixes the problem.

The code below illustrates the problem (at least on my updated Stata
11.2 on Win XP). Uncomment the /* for the expected/correct results.

---------Code begin-------------

clear all
 
set more off
 
set obs 1000
 

*Generate data
g int id =_n
 
g int fup = 1000
 
g byte event = mod(_n/10,1)==0
 
g int start_fup = 100

*first stset

stset fup,id(id) f(event) enter(start_fup)
 
strate
 
stptime

clonevar oldt=_t
 
/* 

*Correct results
 
stset oldt,id(id) f(_d) origin(start_fup)
 
strate
 
stptime

stsplit hej, at(0(50)10000)

exit
 
*/
 
*Second stset with use of previous stset _t

stset _t,id(id) f(_d) origin(start_fup)
 
strate
 
stptime

stsplit hej, at(0(50)10000)

-------------------------Code end-----------------------


Am I just going mad ?

Jesper Lindhardsen
MD, PhD candidate
Department of Cardiovascular Research
Copenhagen University Hospital, Gentofte
Denmark


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