Dealing with data in Cox PH model with exclusively right censoring. My understanding from reading is that right censored data does not contribute to the analysis under Cox models - however a quick experiment shows me that they do affect the HR's and the shape of the survival curve.
library(survival)
n <- 5000
id <- 1:n
sex <- ifelse(rbinom(n, 1, 0.5)==0, "F", "M")
age <- runif(n, 20, 100)
death <- rbinom(n, 1, age/100 )
df1 <- data.frame(id, sex, age, death)
mod1 <- (coxph(Surv(time=age, event=death) ~ sex, df1))
df2 <- df1[df1$death==1,]
mod2 <- (coxph(Surv(time=age, event=death) ~ sex, df2))
summary(mod1)
summary(mod2)
plot(survfit(mod1))
plot(survfit(mod2))
So df2 and thus model2 consists of only the people who experience the outcome. If the right censored folks in model1 don't contribute to the analysis to my mind the results from both analyses should be the same - but comparing the regressions and curves they are not.
What am I missing here ?