Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Bug in stsplit and stptime - or me ?


From   "Jesper Lindhardsen" <JESLIN01@geh.regionh.dk>
To   <statalist@hsphsun2.harvard.edu>
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index