beta0 = c(1,-1)
# Fit proportional hazards model
data(PH_examp)
mod1<-TransModel(formula=Surv(time,status)~gender+age,data=PH_examp,r=0)
print(mod1)
summary(mod1)
mod1$coefficients
mod1$vcov
mod1$converged
# Estimated baseline survival function
pred1<-predict(mod1,covar=data.frame(gender=0,age=0))
plot(pred1)
lines(pred1$time,exp(-((exp(2*pred1$time)-1)/2)),col=3) # True value
### Not Run ###
# survival estimate with 95% pointwise CI and overall CB
# mod1<-TransModel(formula=Surv(time,status)~gender+age,data=PH_examp,r=0,CICB.st=TRUE,num.sim=50)
# pred1<-predict(mod1,covar=data.frame(gender=0,age=0))
# plot(pred1,lty=1,col=1,CI=TRUE,CB=TRUE)
# lines(pred1$time,exp(-((exp(2*pred1$time)-1)/2)),col=3) # True value
# compare survival curve for gender=0 or 1, age=0
# pred2<-predict(mod1,covar=data.frame(gender=1,age=0))
# plot(pred1,lty=2,col=1)
# lines(pred2$time,pred2$survival,type="s",lty=2,col=2)
# lines(pred1$time,exp(-((exp(2*pred1$time)-1)/2)),col=1) # True value
# lines(pred2$time,exp(-((exp(2*pred2$time)-1)/2))^exp(sum(beta0*c(1,0))),col=2) # True value
# Fit proportional odds model
data(PO_examp)
mod2=TransModel(Surv(time,status)~gender+age,data=PO_examp,r=1)
print(mod2)
summary(mod2)
pred2<-predict(mod2,covar=data.frame(gender=0,age=0))
Run the code above in your browser using DataLab