Skip to content

How to stop Kaplan-Meier curve at a time point

5 messages · Dr.Vinay Pitchika, David Winsemius, Thomas Stewart +1 more

#
On Nov 20, 2013, at 12:01 PM, Dr.Vinay Pitchika wrote:

            
I'm assuming that you have a dataframe with those variables and have attached it. If so, then:

dfrm <- detach(said_df)

# If not, then:

dfrm <- data.frame(Survival_days, Outcome, Gender)

Gender2<-survfit(Surv(Survival_days, Outcome)~Gender, 
                  data=dfrm, subset = Survival_days < 6*365.25 )
David Winsemius
Alameda, CA, USA
#
That subset will give you right truncation, not right censoring.  See code below.  Use Thomas's solution.

Chris


library(survival)
set.seed(20131121)
ngroup <- 100
xxx <- rep(0:1, e=ngroup)
ttt <- rexp(length(xxx), rate=xxx+.5)
plot(survfit(Surv(ttt) ~ xxx))
survdiff(Surv(ttt) ~ xxx)

# impose earlier stop time?
tstop <- 2
lines(survfit(Surv(ttt) ~ xxx, subset=ttt<tstop), col=2)
survdiff(Surv(ttt) ~ xxx, subset=ttt<tstop)

# censor at earlier stop time
ddd <- ttt<tstop
ttt2<- pmin(ttt, tstop)

lines(survfit(Surv(ttt2, ddd) ~ xxx), col=3)
survdiff(Surv(ttt2, ddd) ~ xxx)
# green lines match black lines up to tstop




-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Wednesday, November 20, 2013 5:49 PM
To: Dr.Vinay Pitchika
Cc: r-help at r-project.org
Subject: Re: [R] How to stop Kaplan-Meier curve at a time point
On Nov 20, 2013, at 12:01 PM, Dr.Vinay Pitchika wrote:

            
I'm assuming that you have a dataframe with those variables and have attached it. If so, then:

dfrm <- detach(said_df)

# If not, then:

dfrm <- data.frame(Survival_days, Outcome, Gender)

Gender2<-survfit(Surv(Survival_days, Outcome)~Gender, 
                  data=dfrm, subset = Survival_days < 6*365.25 )
David Winsemius
Alameda, CA, USA


**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues
#
On Nov 21, 2013, at 5:08 AM, Andrews, Chris wrote:

            
I completely agree that my strategy was wrong. It inappropriately removed the long-lived cases from the riskset at earlier times so there would be an over-estimate of risk in proportion to the ratio of such cases to the entire population.