# NOT RUN {
library(survPen)
data(datCancer) # simulated dataset with 2000 individuals diagnosed with cervical cancer
# model : unidimensional penalized spline for time since diagnosis with 5 knots
f1 <- ~smf(fu,df=5)
# hazard model
mod1 <- survPen(f1,data=datCancer,t1=fu,event=dead,expected=NULL,method="LAML")
# predicting hazard and survival at time 1
pred <- predict(mod1,data.frame(fu=1))
pred$haz
pred$surv
# predicting hazard ratio between age 70 and age 30
pred.HR <- predict(mod1,data.frame(fu=1,age=70),newdata.ref=data.frame(fu=1,age=30),type="HR")
pred.HR$HR
pred.HR$HR.inf
pred.HR$HR.sup
# }
Run the code above in your browser using DataLab