rsurvival-analysisconfidence-intervalsurvivalhazard

Plotting Hazard Function with bshazard package + Hazard ratios in life table


I'm trying to plot the hazard function of a survival analysis I'm doing for my PhD, comparing the hazard rate of two different conditions.

I can't find a way to make the code function as intended (here for reference, Fig. 4, page 7), in order to obtain the confidence intervals of the smoothed hazard lines for both levels of the predictor variable.

I'm adding my code for reference:

fitt<-bshazard(Surv(time,event) ~ session.type,data=data,lambda=10,nbin=60) 
plot(fitt,overall=FALSE, col=1, conf.int = TRUE)

The function "overall=FALSE" gives me two smoothed hazard curves both does not include the confidence intervals, which I need to extrapolate results from the plot. Here an image of the plot I obtained from the code:

enter image description here

If anyone knows a way to obtain the hazard rates (with upper and lower confidence intervals) in a time table in order to know those values for each time interval, it would help me a lot.

Thanks to anyone who could help!


Solution

  • One way is to run the function bshazard stratifying data by the two levels of the session.type. Considering session.type with two levels (for example 0 and 1) your code to obtain the hazard rates (with upper and lower confidence intervals) is:

    -for session.type = 0:

    Fitt0 <- bshazard(Surv(time,evento) ~1, data= data [data$session.type ==0,],lambda=10,nbin=60)
    plot(fitt0,overall=TRUE, col=1, conf.int = TRUE)
    

    -for level session.type=1

    Fitt1 <- bshazard(Surv(time,evento) ~1, data= data [data$session.type ==1,],lambda=10,nbin=60)
    plot(fitt1,overall=TRUE, col=1, conf.int = TRUE)