How to Build a Cox Spline Hazard Model

I have the following model:

coxph(Surv(fulength, mortality == 1) ~ pspline(predictor)) 

where fulength is the duration of observation (including mortality), the predictor is a predictor of mortality.

The output of the command above:

  coef se(coef) se2 Chisq DF p pspline(predictor), line 0.174 0.0563 0.0562 9.52 1.00 0.002 pspline(predictor), nonl 4.74 3.09 0.200 

How can I build this model to get a nice seductive line with 95% confidence ranges and a risk factor on the y axis? What I'm aiming for is something like this:

enter image description here

+5
source share
1 answer

Is this when you get it, when you run the first example in? cph from rms package:

 n <- 1000 set.seed(731) age <- 50 + 12*rnorm(n) label(age) <- "Age" sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4))) cens <- 15*runif(n) h <- .02*exp(.04*(age-50)+.8*(sex=='Female')) dt <- -log(runif(n))/h label(dt) <- 'Follow-up Time' e <- ifelse(dt <= cens,1,0) dt <- pmin(dt, cens) units(dt) <- "Year" dd <- datadist(age, sex) options(datadist='dd') S <- Surv(dt,e) f <- cph(S ~ rcs(age,4) + sex, x=TRUE, y=TRUE) cox.zph(f, "rank") # tests of PH anova(f) plot(Predict(f, age, sex)) # plot age effect, 2 curves for 2 sexes 

enter image description here

Since the rms / Hmisc package combination uses lattice graphics, the annotation with the limit function of the age density must be performed using the lattice functions. On the other hand, if you want to change the response value to a relative danger, you can simply add the argument "fun = exp" to call Predict and associate a graph with it:

 png(); plot(Predict(f, age, sex, fun=exp), ylab="Relative Hazard");dev.off() 

enter image description here

+4
source

Source: https://habr.com/ru/post/989912/


All Articles