1. dd <- datadist(be)
    2. options(datadist='dd')
    3. fit8 <-lrm(O ~ rcs(uic, 5)+sex+age+edu+income+smoke+ethnic+BMI,data=be)
    4. an<-anova(fit8)
    5. b<-Predict(fit8, uic,fun=exp)
    6. plot(Predict(fit8, uic,fun=exp), anova=an, pval=T)
    7. dd$limits$uic[2] <-50
    8. fit9=update(fit8)
    9. OR4<-Predict(fit9, uic,fun=exp,ref.zero = TRUE,np=2000)
    10. p5<-ggplot()+geom_line(data=OR4, aes(uic,yhat),linetype=1,size=1,alpha = 0.9,colour="#5599FF")+
    11. geom_ribbon(data=OR4, aes(uic,ymin = lower, ymax = upper),alpha = 0.3,fill="#98F898")+
    12. geom_hline(yintercept=1, linetype=3,size=1,colour="#888888")+
    13. geom_vline(xintercept=2.34, linetype=2,size=0.5,colour="#888888")+
    14. geom_vline(xintercept=2.08, linetype=2,size=0.5,colour="#888888")+
    15. geom_density(data=be,aes(uic,y = ..count../sum(..count..)*500),fill="#FF4500", alpha = 0.2,linetype=3,colour="#A9A9A9") +
    16. theme_classic()+
    17. labs(title = "O", x="U", y="OR(95%CI)")+
    18. scale_x_continuous(breaks = seq(0, 100, by = 0.5),limits = c(1,4.5))+
    19. scale_y_continuous(name = "OR(95%CI)",sec.axis = sec_axis(~.x/500, name = "TS density"))