options( width=120 )
library( survival )
data( lung )
head( lung )
Lx <- Lexis( exit=list( tfd=time),
             exit.status=(status==2), data=lung )
summary( Lx, scale=365.25 )
head( Lx )
Sx <- splitLexis( Lx, "tfd", breaks=c(0,unique(Lx$time)) )
summary( Sx, scale=365.25 )
subset( Sx, lex.id==96 )
c1 <- coxph( Surv(time,status==2) ~ sex + pat.karno, data=lung )
c2 <- coxph( Surv(tfd,tfd+lex.dur,lex.Xst==TRUE) ~ sex + pat.karno, data=Lx )
system.time(
p1 <- glm( lex.Xst ~ factor(tfd) + sex + pat.karno,
           offset = log(lex.dur), family=poisson,
           data=Sx ) )
p2 <- glm( lex.Xst ~ ns(tfd,df=5) + sex + pat.karno,
           offset = log(lex.dur), family=poisson,
           data=Sx )
p3 <- glm( lex.Xst ~ ns(tfd,df=2) + sex + pat.karno,
           offset = log(lex.dur), family=poisson,
           data=Sx )
ee <- rbind( ci.exp( c1 ), ci.exp( c2 ),
             ci.exp( p1, subset=c("sex","pat") ),
             ci.exp( p2, subset=c("sex","pat") ),
             ci.exp( p3, subset=c("sex","pat") ) )
wh <- 1:5*2
round( cbind( ee[wh-1,], ee[wh,] ), 4 )
