Reputation: 587
df <- data.frame(PatientID = c("0002" ,"0002", "0005", "0005" ,"0009" ,"0009" ,"0018", "0018" ,"0039" ,"0039" , "0043" ,"0043", "0046", "0046" ,"0048" ,"0048"),
time = c( 1961.810 , 929.466 , 978.166, 1005.820 , 925.752 , 969.469 ,943.398 , 965.292 , 1996.404 , 967.047 , NA , 893.428 , 921.606 , 976.192 , 929.590 , 950.493),
event = c(1 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 , 0 , 1 ,1 , 0 ,0 ,0 , 1),
BMI = c( 10.140 , 20.810 , 24.466 , 31.166, 26.469 , 40.398 ,20.034, 23.292 , 50.404 , 19.610 , 20.047, 37.517 , 36.428 , 19.606 , 20.590 ,29.493), stringsAsFactors = F)
A bit of an abstract question but I would like to create a plot where in the X axis I have body mass index (continuous variable) and in the Y axis I want to plot the hazard ratios of BMI associated to the risk of experiencing an event (we'll call the event df$event)
I have attached a plot that is an example of what I want to plot and the link to the paper from where this is from: https://www.thelancet.com/journals/landia/article/PIIS2213-8587%2818%2930288-2/fulltext
I have found this document but I don't really understand it properly: https://blogs.bu.edu/gagnon/files/2021/02/README-Restricted-Cubic-Spline-Plots.pdf
I would like to do this plot in R software.
ALTERNATIVE "DIRTY" WAY OF PLOTTING THIS:
Do univariate cox regressions of 5 cutt-offs (bmi >10, >20, >30, >40, >50) and then plot that in a x,y plot. But in this case, how could we introduce the CI that are derived from the cox regression?
Thank you so much for your help!
Upvotes: 1
Views: 917