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]

RE: st: snapsan command


From   Kieran McCaul <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: snapsan command
Date   Tue, 22 May 2012 10:29:02 +0800

...


Sara,

I don't think you have understood -snapspan-.

In the snapspan.dta example data, the variables x1 and x2 have been measured AT THE SPECIFIC TIMES recorded in the variable time.

If I ignore this and simply -stset- the data prior to running a Cox model, the data will be set up incorrectly.

To see this, look at the new variables _t0 and _t in the first listing below.  These are intervals of times - time-spans - within which the values of the variables x1 and x2 are fixed.  As you can see, for id=1 the data are saying that x1=10 and x2=20 in the time-span 0 to 5; x1=10 and x2=23 in the time-span 5 to 7; and x1=10 and x2=18 in the time-span 7 to 9.

But this is wrong. x1=10 and x2=20 when time=5 and doesn't change until time=7 when x1=10 and x2=23 and doesn't change again until time=9 when x1=10 and x2=18.  Person id=1 has data recorded at three time points and these define two time-spans: 5 to 7 and 7 to 9. 

Consequently, when we set up the data for a Cox model using -stset- we want it to have two time-spans, not three. (See the second listing below).
We don't know the value of x1 and x2 before time=5, so x1 and x2 will be missing for the time-span 0 to 5. 

The time-span 0 to 5 (for id=1) has been created by stset, because it is assuming that observation started at time=0, the default.

Alternatively, I could instead use -stset time, f(event) enter(time) id(id)- and then for id=1, _t0 and _t will be missing prior to time=5. (the third listing below.)


* 1. --- WITHOUT USING SNAPSPAN ---
. webuse snapspan, clear
. stset time, f(event) id(id)
. list, sepby(id)

     +---------------------------------------------------+
     | id   time   x1   x2   event   _st   _d   _t   _t0 |
     |---------------------------------------------------|
  1. |  1      5   10   20       0     1    0    5     0 |
  2. |  1      7   10   23       0     1    0    7     5 |
  3. |  1      9   10   18       1     1    1    9     7 |
     |---------------------------------------------------|
  4. |  2      6    8   13       0     1    0    6     0 |
  5. |  2     10    8   15       0     1    0   10     6 |
  6. |  2     13    8   18       1     1    1   13    10 |
     |---------------------------------------------------|
  7. |  3      4    4   19       0     1    0    4     0 |
  8. |  3      7    4   24       1     1    1    7     4 |
     |---------------------------------------------------|
  9. |  4      2    6   10       0     1    0    2     0 |
 10. |  4      9    6   20       1     1    1    9     2 |
     +---------------------------------------------------+

* 2. --- USING SNAPSPAN ---
. webuse snapspan, clear
. snapspan id time event
. stset time, f(event) id(id)
. list, sepby(id)
     +---------------------------------------------------+
     | id   time   x1   x2   event   _st   _d   _t   _t0 |
     |---------------------------------------------------|
  1. |  1      5    .    .       0     1    0    5     0 |
  2. |  1      7   10   20       0     1    0    7     5 |
  3. |  1      9   10   23       1     1    1    9     7 |
     |---------------------------------------------------|
  4. |  2      6    .    .       0     1    0    6     0 |
  5. |  2     10    8   13       0     1    0   10     6 |
  6. |  2     13    8   15       1     1    1   13    10 |
     |---------------------------------------------------|
  7. |  3      4    .    .       0     1    0    4     0 |
  8. |  3      7    4   19       1     1    1    7     4 |
     |---------------------------------------------------|
  9. |  4      2    .    .       0     1    0    2     0 |
 10. |  4      9    6   10       1     1    1    9     2 |
     +---------------------------------------------------+

* 3. --- USING SNAPSPAN AND SPECIFYING ENTER() IN STSET ---
. webuse snapspan, clear
. snapspan id time event
. stset time, f(event) enter(time) id(id)
. list, sepby(id)

     +---------------------------------------------------+
     | id   time   x1   x2   event   _st   _d   _t   _t0 |
     |---------------------------------------------------|
  1. |  1      5    .    .       0     0    .    .     . |
  2. |  1      7   10   20       0     1    0    7     5 |
  3. |  1      9   10   23       1     1    1    9     7 |
     |---------------------------------------------------|
  4. |  2      6    .    .       0     0    .    .     . |
  5. |  2     10    8   13       0     1    0   10     6 |
  6. |  2     13    8   15       1     1    1   13    10 |
     |---------------------------------------------------|
  7. |  3      4    .    .       0     0    .    .     . |
  8. |  3      7    4   19       1     1    1    7     4 |
     |---------------------------------------------------|
  9. |  4      2    .    .       0     0    .    .     . |
 10. |  4      9    6   10       1     1    1    9     2 |
     +---------------------------------------------------+








______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M577)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: [email protected]
http://myprofile.cos.com/mccaul 
http://www.researcherid.com/rid/B-8751-2008

"One can be beaten up in school simply by referring to oneself as one" - Sheldon
__________________________________________________________________________
IMPORTANT: This email is intended for the use of the individual addressee(s) named above and may
contain information that is confidential, privileged or unsuitable for overly sensitive persons with low
self-esteem, no sense of humour or irrational religious beliefs. If you are not the intended recipient, 
any dissemination, distribution or copying of this email is not authorised (either explicitly or implicitly) 
and constitutes an irritating social faux pas.



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