# make time log
lung$log_time<-log(lung$time)
#Model
res.cox <- coxph(Surv(time, status) ~ sex*log_time, data = lung)
## Warning in coxph.fit(X, Y, istrat, offset, init, control, weights = weights, :
## Ran out of iterations and did not converge
## Warning in coxph.fit(X, Y, istrat, offset, init, control, weights = weights, :
## one or more coefficients may be infinite
summary(res.cox)
## Call:
## coxph(formula = Surv(time, status) ~ sex * log_time, data = lung)
##
## n= 228, number of events= 165
##
## coef exp(coef) se(coef) z Pr(>|z|)
## sex -2.848e+00 5.798e-02 2.489e-01 -11.440 <2e-16 ***
## log_time -1.847e+02 5.992e-81 2.150e+01 -8.593 <2e-16 ***
## sex:log_time 4.791e-01 1.615e+00 4.458e-02 10.749 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## sex 5.798e-02 1.725e+01 3.559e-02 9.444e-02
## log_time 5.992e-81 1.669e+80 3.012e-99 1.192e-62
## sex:log_time 1.615e+00 6.193e-01 1.480e+00 1.762e+00
##
## Concordance= 1 (se = 0 )
## Likelihood ratio test= 1374 on 3 df, p=<2e-16
## Wald test = 320.2 on 3 df, p=<2e-16
## Score (logrank) test = 530.1 on 3 df, p=<2e-16
#Plot
plot(cox.zph(res.cox))


