I have attached a picture of a Spline Curve produced with rms package in R. It shows the association between the hazard ratio (death) in relation to a given cumulative dosage of a drug.
Please find my data and scripts below.
I have used the rms package. I wish to find x-value (w$total.mbq) that belongs to the hazard ratio = y = 1. I have tried different combinations of summary(model)
but it does not work.
library(ggplot2)
library(rms)
d <- datadist(w)
options(datadist="d")
model <- cph(Surv(Follow.up.death,Death)~rcs(total.mbq),data=w)
ggplot(Predict(model, fun=exp)) + scale_y_continuous(breaks=c(1:10))
My data
w <- structure(list(Follow.up.death = c(18, 2, 14, 17, 31, 4, 20,
15, 12, 19, 10, 17, 27, 22, 3, 43, 24, 14, 13, 5, 12, 137, 22,
87, 48, 24, 72, 32, 14, 83, 68, 56, 57, 18, 16, 70, 1.9, 69.2,
126.3, 41.6, 17.9, 1.3, 87.4, 4.4, 137.4, 17.5, 95.8, 65.2, 14.8,
98.5, 16.6, 74.9, 10.3, 43.4, 32.5, 4.8, 7.3, 107.8, 6.8, 18.3,
33, 25.2, 49.2, 15.9, 1.2, 42.7, 1, 9, 1.8, 15.6, 8.9, 15, 16.4,
7.7, 75.5, 12.2, 54.8, 22.2, 9.7, 14.3, 5.2, 64.5, 21.8, 0.2,
7.3, 18.7, 5.1, 17.3, 27.4, 16, 24.2, 9.7, 8.2, 5.7, 41.8, 10.6,
22.8, 4.8, 6, 4, 50, 21, 30, 5, 11, 12), Death = c(0L, 1L, 1L,
0L, 0L, 1L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L,
1L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 1L, 0L, 1L, 0L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 0L), total.mbq = c(29354L, 7445L, 22309L,
29699L, 29711L, 14765L, 22257L, 29715L, 29772L, 13320L, 20905L,
12950L, 3400L, 14800L, 7400L, 21890L, 19400L, 14800L, 14700L,
22200L, 1688L, 4500L, 8438L, 13500L, 14800L, 12580L, 12950L,
13320L, 11840L, 13320L, 14800L, 13690L, 11250L, 12210L, 13320L,
13320L, 14800L, 12580L, 20720L, 11840L, 14800L, 7030L, 14800L,
14800L, 8325L, 11100L, 10730L, 13690L, 12210L, 14800L, 13320L,
14800L, 12950L, 22200L, 17945L, 22200L, 8140L, 13690L, 11581L,
14430L, 13320L, 13320L, 21090L, 11100L, 3885L, 6475L, 6660L,
6660L, 5920L, 7500L, 5000L, 12500L, 12500L, 10000L, 12500L, 7500L,
15000L, 10000L, 5000L, 7500L, 5000L, 15000L, 12500L, 7500L, 7500L,
7500L, 5000L, 10000L, 10000L, 10000L, 12500L, 5000L, 5000L, 10000L,
12500L, 5000L, 10000L, 10000L, 22200L, 14800L, 29000L, 14000L,
4800L, 21600L, 28800L, 11400L)), .Names = c("Follow.up.death",
"Death", "total.mbq"), class = "data.frame", row.names = c(NA,
-106L))
f <- Function(model) # create an R function for X*beta hat = log relative hazard
This is a function of total.mbq
. Use an R root solver to solve for f(x) = 0. I think the result is the median total.mbq
. On the other hand I may have solved for the centering constant so that the mean log hazard over all subjects is zero. Wish I remembered the details right now.