I have using following cox model to investigate the association between two exposures and a time to event outcome (0=no event, 1=event).
Model= coxph(Surv(time, as.numeric(event))~V1+V2, data=data)
Where v1=exposure1, v2=exposure2
I would like to predict the difference in risk due to difference in these two exposures. Thus I created a new dataset with the new values of exposures and used that dataset to predict a diference in rsik due to difference in exposures. This new dataset with new values looks like this
newdata= data.frame(V1=c(-2.17, -1.99), V2=c(.44, .43))
For this, I used the following function on this newdata to predict risk associated with new exposure values.
Prediction=predict(Model, newdata=newdata)
this gives me this output (hazards)
-0.66 , -0.60
Based on this output I can calculate the difference in risk due to difference in exposure like this
Prediction[1]-Prediction[2]
But I am struggling to calculate the 95% confidence interval of this difference in risk. Any suggestions on how I can calculate this?
Somebody in this post (Cox regression. Find 95% confidence interval for comparison of two groups) suggested to use ‘contrast’ function from rms package but I am not sure how to use this function since I have never used that package. Any suggestions on how to calculate such 95%CI?