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]

Re: st: weighted time dependent Cox model


From   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: weighted time dependent Cox model
Date   Sat, 18 Feb 2012 22:54:51 -0500

In Stata, -enter- refers to the earliest entry time for a subject, and -exit- to the last observed time. (This is in the Manual entry for -stset-).  Use this -stset- statement:

****************************************************
stset exit [pweight=weight], fail(event)  id(id)
****************************************************'

Steve
sjsamuels@gmail.com

On Feb 18, 2012, at 6:07 PM, Ehsan Karim wrote:

Dear Stata list,

I am trying to reproduce the weighted time dependent Cox model
(Andersen–Gill format with IPTW) results in Stata that are originally
obtained from R using same dataset, but so far getting the estimates
different. Could anyone indicate what I could be done to fix this?

Any suggestions/references will be highly appreciated.

Thanks,

Ehsan



##########################################
# R results: coef -0.288 se 0.174
##########################################

> dataset = read.csv("http://stat.ubc.ca/~e.karim/dataset.csv";)
> msmc = coxph(Surv(enter, exit, event) ~ tx + cluster(id), robust = TRUE, data = dataset, weights = weight)
> summary(msmc)
 n= 14372, number of events= 131

     coef exp(coef) se(coef) robust se      z Pr(>|z|)
tx -0.2882    0.7496   0.1745    0.1964 -1.467    0.142

  exp(coef) exp(-coef) lower .95 upper .95
tx    0.7496      1.334    0.5101     1.102

Concordance= 0.534  (se = 0.021 )
Rsquare= 0   (max possible= 0.136 )
Likelihood ratio test= 2.8  on 1 df,   p=0.09455
Wald test            = 2.15  on 1 df,   p=0.1423
Score (logrank) test = 2.75  on 1 df,   p=0.09739,   Robust = 2.11  p=0.1459

##########################################
# Stata results: coef -.605 se .643
##########################################

. use http://stat.ubc.ca/~e.karim/dataset, clear
(6 vars, 14372 obs)
. stset exit [pweight=weight], fail(event) exit(exit) id(id) enter(enter)
               id:  id
    failure event:  event != 0 & event < .
obs. time interval:  (exit[_n-1], exit]
enter on or after:  time enter
exit on or before:  time exit
           weight:  [pweight=weight]
------------------------------------------------------------------------------
   14372  total obs.
   12872  obs. begin on or after exit
------------------------------------------------------------------------------
    1500  obs. remaining, representing
    1500  subjects
      17  failures in single failure-per-subject data
    1500  total analysis time at risk, at risk from t =         0
                            earliest observed entry t =         0
                                 last observed exit t =         1

. stcox tx, nohr robust nolog
        failure _d:  event
  analysis time _t:  exit
 enter on or after:  time enter
 exit on or before:  time exit
                id:  id
            weight:  [pweight=weight]
(sum of wgt is   1.5062e+03)

Cox regression -- Breslow method for ties

No. of subjects      =  1506.227846                Number of obs   =      1500
No. of failures      =  17.16531456
Time at risk         =  1506.227846
                                                  Wald chi2(1)    =      0.89
Log pseudolikelihood =   -124.48415                Prob > chi2     =    0.3464

                                 (Std. Err. adjusted for 1500 clusters in id)
------------------------------------------------------------------------------
            |               Robust
         _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         tx |  -.6053404   .6428669    -0.94   0.346    -1.865336    .6546555
------------------------------------------------------------------------------

##########################################
# dataset (partial)
##########################################
. list
      +-------------------------------------------------------------------+
      |   id   tx   event   enter   exit     weight   _st   _d   _t   _t0 |
      |-------------------------------------------------------------------|
   1. |    1    0       0       0      1   1.356058     1    0    1     0 |
   2. |    1    0       0       1      2   1.356058     0    .    .     . |
   3. |    1    0       0       2      3   1.356058     0    .    .     . |
   4. |    1    1       0       3      4   1.356058     0    .    .     . |
   5. |    1    0       0       4      5   1.356058     0    .    .     . |
   6. |    1    0       0       5      6   1.356058     0    .    .     . |
   7. |    1    0       0       6      7   1.356058     0    .    .     . |
   8. |    1    0       0       7      8   1.356058     0    .    .     . |
   9. |    1    0       0       8      9   1.356058     0    .    .     . |
  10. |    1    1       0       9     10   1.356058     0    .    .     . |
      |-------------------------------------------------------------------|
  11. |    2    0       0       0      1    1.57168     1    0    1     0 |
  12. |    2    0       0       1      2    1.57168     0    .    .     . |
  13. |    2    1       0       2      3    1.57168     0    .    .     . |
  14. |    2    0       0       3      4    1.57168     0    .    .     . |
  15. |    2    1       0       4      5    1.57168     0    .    .     . |
  16. |    2    1       0       5      6    1.57168     0    .    .     . |
  17. |    2    1       0       6      7    1.57168     0    .    .     . |
  18. |    2    0       0       7      8    1.57168     0    .    .     . |
  19. |    2    0       0       8      9    1.57168     0    .    .     . |
  20. |    2    0       0       9     10    1.57168     0    .    .     . |
      |-------------------------------------------------------------------|
  21. |    3    0       0       0      1    .983771     1    0    1     0 |
  22. |    3    0       0       1      2    .983771     0    .    .     . |
  23. |    3    0       0       2      3    .983771     0    .    .     . |
  24. |    3    0       0       3      4    .983771     0    .    .     . |
  25. |    3    1       0       4      5    .983771     0    .    .     . |
  26. |    3    0       0       5      6    .983771     0    .    .     . |
  27. |    3    0       0       6      7    .983771     0    .    .     . |
  28. |    3    0       0       7      8    .983771     0    .    .     . |
  29. |    3    1       0       8      9    .983771     0    .    .     . |
  30. |    3    0       0       9     10    .983771     0    .    .     . |
--more--

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


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