I am using R survdiff (survival package).
I would like to focus the analysis on the first 2 years of my survival curve (that is actually much longer, but with few cases in the long term and with possible superimposed curves between the groups).
What should I do to focus the analysis on these first 2 years only?
Should I subset the dataset?
Best Answer
Before proceeding, you should ask yourself "Why limit follow-up to two years?" If there is some rational reason for truncating follow-up at two years and you are committed to using the Kaplan-Meier method and the log-rank test, you will need to recode your censoring indicator and the follow-up time to reflect a maximum follow-up of two years:
#load required package install.packages("survival") library("survival") #generate the data set.seed(42) time <- abs(rnorm(42, mean=0, sd=1 ))*1800 event <- sample( c(0,0,1), 42, replace=TRUE) group <- sample( c(1,2), 42, replace=TRUE) #reform data for maximum follow-up of two years time_730 <- ifelse(time>=730, 730, time) event_730 <- ifelse(time>=730, 0, event) #logrank test at two years summary( Surv(time_730, event_730)) survdiff( Surv(time_730, event_730) ~ group)
You mention overlapping curves or violation of the proportional hazards assumption. If this assumption is violated, you will need to look carefully at your curves before accepting the logrank p-value as a true test of the equality of survival experiences.
Similar Posts:
- Solved – How to calculate the HR and 95%CI using the log-rank test in R
- Solved – p-value zero in hypothesis testing for survival curves
- Solved – p-value zero in hypothesis testing for survival curves
- Solved – p-value zero in hypothesis testing for survival curves
- Solved – p-value zero in hypothesis testing for survival curves