Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. id<-c(rep(1,5),rep(2,5),rep(3,5))
  2. year<-c(rep(2000:2004,3))
  3. event<-c(0,0,1,0,0,0,0,0,0,0,0,1,0,1,0)
  4. sequence<-c(1,1,1,2,2,1,1,1,1,1,1,1,2,2,3)
  5. seq_year<-c(1,2,3,1,2,1:5,1,2,1,2,1)
  6. df<-data.frame(id,year,event,sequence,seq_year)
  7. set.seed(1)
  8. df$x<-rnorm(15)
  9.  
  10. df
  11. id year event sequence seq_year x
  12. 1 1 2000 0 1 1 -0.6264538
  13. 2 1 2001 0 1 2 0.1836433
  14. 3 1 2002 1 1 3 -0.8356286
  15. 4 1 2003 0 2 1 1.5952808
  16. 5 1 2004 0 2 2 0.3295078
  17. 6 2 2000 0 1 1 -0.8204684
  18. 7 2 2001 0 1 2 0.4874291
  19. 8 2 2002 0 1 3 0.7383247
  20. 9 2 2003 0 1 4 0.5757814
  21. 10 2 2004 0 1 5 -0.3053884
  22. 11 3 2000 0 1 1 1.5117812
  23. 12 3 2001 1 1 2 0.3898432
  24. 13 3 2002 0 2 1 -0.6212406
  25. 14 3 2003 1 2 2 -2.2146999
  26. 15 3 2004 0 3 1 1.1249309
  27.  
  28. summary(coxph(Surv(year-1,year,event) ~ x + cluster(id) + strata(sequence), data=df)) ###tstart from year
  29. summary(coxph(Surv(seq_year-1,seq_year,event)~x + cluster(id) + strata(sequence), data=df)) ###tstart from sequence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement