Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id<-c(rep(1,5),rep(2,5),rep(3,5))
- year<-c(rep(2000:2004,3))
- event<-c(0,0,1,0,0,0,0,0,0,0,0,1,0,1,0)
- sequence<-c(1,1,1,2,2,1,1,1,1,1,1,1,2,2,3)
- seq_year<-c(1,2,3,1,2,1:5,1,2,1,2,1)
- df<-data.frame(id,year,event,sequence,seq_year)
- set.seed(1)
- df$x<-rnorm(15)
- df
- id year event sequence seq_year x
- 1 1 2000 0 1 1 -0.6264538
- 2 1 2001 0 1 2 0.1836433
- 3 1 2002 1 1 3 -0.8356286
- 4 1 2003 0 2 1 1.5952808
- 5 1 2004 0 2 2 0.3295078
- 6 2 2000 0 1 1 -0.8204684
- 7 2 2001 0 1 2 0.4874291
- 8 2 2002 0 1 3 0.7383247
- 9 2 2003 0 1 4 0.5757814
- 10 2 2004 0 1 5 -0.3053884
- 11 3 2000 0 1 1 1.5117812
- 12 3 2001 1 1 2 0.3898432
- 13 3 2002 0 2 1 -0.6212406
- 14 3 2003 1 2 2 -2.2146999
- 15 3 2004 0 3 1 1.1249309
- summary(coxph(Surv(year-1,year,event) ~ x + cluster(id) + strata(sequence), data=df)) ###tstart from year
- 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