I’m running a code to generate a survival estimate. It works. However, I want to add information to the code like hazard / risk ratio and p-value. Here is the code
#Using Survival package
#Create a Data Frame composed of = ID, Time, Age, Intervention, Outcome
ID = df$CaseCode
Time = df$MW
Age = df$age10
Intervention = df$intervention #quarantine
outcome = df$severe
#Creating Data Frame
surv_df ← data.frame(ID=ID, Age = Age, Intervention=Intervention, Time=Time, Outcome=outcome)
check assumption of proportional hazards
gsurv ← survfit(Surv(Time, outcome) ~ Intervention, data = surv_df)
summary(gsurv)
plot of cumulative survival probabilities
if (pdfind) { pdf(file = “figure1A.pdf”, width = 10.2, height = 5) }
par(oma = c(2, 2, 0.5, 0.5), mar = c(2, 2, 0, 0))
plot(gsurv, lty = 1:2, las = 1, lwd = 2)
mtext(side = 1, line = 2.5, text = “time (time)”, cex = 1.2)
mtext(side = 2, line = 3, text = “survival distribution function”, cex = 1.2)
legend(“topright”, title = “Intervention”, legend = c(“no”, “yes”),
lty = 1:2, inset = 0.05, bty = “n”, cex = 1.4)