+ Reply to Thread
Results 1 to 14 of 14

Thread: Survival Analysis with Interval Censored Data

  1. #1
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Survival Analysis with Interval Censored Data




    Dear All

    I'm trying to do a survival analysis with interval censored data.

    The data are basically eye pressure measurements at certain intervals (18 months, 2 years and 3 years) after an operation to reduce eye pressure.

    The operation is said to have 'failed' if the pressure rises above a predetermined level at any of the examination points. Different levels are set to show survival curves at different stringencies of success, if that makes sense. So survival curves will be drawn for failure defined as greater than 15, greater than 18 and greater than 21.

    Now, the data is interval censored in that we only know that someone failed between two clinic visits.

    So, can anyone help me with how I should organise my data in, preferably SPSS, or, if necessary, in R, so that I can correctly draw the survival curves and do the survival analysis with interval censored data.

    All examples I've seen so far of this assume that the data is not interval censored...

    Many Thanks

    Simon

  2. #2
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    Ok, the link below should get me started but any additional help would be greatly appreciated!

    http://www.google.co.uk/url?sa=t&rct...FDyHQakSLTldAQ

  3. #3
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    Ok finally did it..... so problem solved!

  4. #4
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    Dear R user friends

    I have managed to solve my problem using R but I think that my workflow is currently a little inefficient.

    I have a macro in Excel that reads the data and compares it to my cut-off pressure level. This macro creates 3 columns of data for the R surv function: time1, time2, event.

    Event = 0 if right censored and 3 if interval censored.

    I make this into a .csv file and read into R with:

    data1 <- read.table("IOPless15.csv", header=F, sep=",")

    I then have to separate this out with the following commands before I can do my final surv command

    So I have to do

    lefttimes=c(data1[(rep(1:51,each=1)),1])
    righttimes=c(data1[(rep(1:51,each=1)),2])
    myevents=c(data1[(rep(1:51,each=1)),3])

    and finally

    mysurv=Surv(lefttimes,righttimes,myevents,c("interval"))

    and to produce the Kaplan-Meier plot

    mysurvfit = survfit(mysurv~1)
    plot(mysurvfit)

    Now, can anyone tell me how I can read the .csv file directly into lefttimes, righttimes and myevents so I don't have to split up the data1 matrix as it feels quite inefficient.

    Thank you!

    Simon

  5. #5
    Devorador de queso
    Points: 95,754, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,932
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Survival Analysis with Interval Censored Data

    You can use read.csv if it really is a csv file. You can use the col.names parameter if you don't have the header but want to specify column names while importing.

    Is there a reason you're using rep(1:51, each = 1) instead of just 1:51? Also you don't need to wrap everything in c().

    lefttimes <- data1[1:51, 1] should do the same thing. "inter val" is the same as c("inter val").
    I don't have emotions and sometimes that makes me very sad.

  6. The Following User Says Thank You to Dason For This Useful Post:

    SiBorg (03-10-2012)

  7. #6
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    Is there a reason you're using rep(1:51, each = 1) instead of just 1:51?
    Because I really don't know what I'm doing with R at the moment! Have just ordered a book from Amazon so hopefully will get better with this.

    Thanks for the hints - your version of the commands will be much simpler to type and edit!

    I don't want to specify column names as such, I would ideally like to read each column directly into its correct variable name. Can I do this, or do I need to do the lefttimes <- data1[1:51, 1] thing for each variable?

    Thanks again.

  8. #7
    Devorador de queso
    Points: 95,754, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,932
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Survival Analysis with Interval Censored Data

    It's probably better practice to keep the data stored in the data frame since the data is logically grouped together in that fashion.

    Code: 
    data1 <- read.csv("IOPless15.csv", header = FALSE, col.names = c("lefttimes", "righttimes", "myevents"))
    
    mysurv <- with(data1, Surv(lefttimes, righttimes, myevents, "inter val"))
    
    #of if you absolutely insist on being able to refer to them like
    #they're objects in your environment
    attach(data1)
    
    mysurv <- Surv(lefttimes, righttimes, myevents, "inter val")
    I don't have emotions and sometimes that makes me very sad.

  9. The Following User Says Thank You to Dason For This Useful Post:

    SiBorg (03-10-2012)

  10. #8
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    The first two lines is what I really wanted to do but didn't know how. Thank you very much Dason.

  11. #9
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    One last question (I hope)

    I now have two survival curves which I have plotted separately as follows:

    plot(mysurvfit)
    plot(mysurvfit2)

    Can anyone tell me how to superimpose these plots with the second in a different colour?

    Thanks in advance.

  12. #10
    TS Contributor
    Points: 22,410, Level: 93
    Level completed: 6%, Points required for next Level: 940

    Posts
    3,020
    Thanks
    12
    Thanked 565 Times in 537 Posts

    Re: Survival Analysis with Interval Censored Data

    Try to add the argument

    plot(mysurvfit2,add=T,col=...)

    Just choose a color number in ... as you want.

    see R color chart:
    http://research.stowers-institute.or...R/Color/Chart/

  13. #11
    Devorador de queso
    Points: 95,754, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    Posting AwardCommunity AwardDiscussion EnderFrequent Poster
    Dason's Avatar
    Location
    Tampa, FL
    Posts
    12,932
    Thanks
    307
    Thanked 2,629 Times in 2,245 Posts

    Re: Survival Analysis with Interval Censored Data

    Does this work?

    Code: 
    plot(mysurvfit)
    lines(mysurvfit2, col = "red")
    I haven't used survival in quite some time so I don't remember if that gives you what you want or not.
    I don't have emotions and sometimes that makes me very sad.

  14. The Following User Says Thank You to Dason For This Useful Post:

    SiBorg (03-10-2012)

  15. #12
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    Thanks Dason the col bit helped - I didn't know how to set colours

    So I got it to work with

    plot(mysurvfit)
    par(new=TRUE)
    plot(mysurvfit2, col = "red")

    Thanks again for your help.

  16. #13
    Points: 5,259, Level: 46
    Level completed: 55%, Points required for next Level: 91
    SiBorg's Avatar
    Posts
    255
    Thanks
    71
    Thanked 25 Times in 22 Posts

    Re: Survival Analysis with Interval Censored Data

    So here are my survival curves (see attached)

    Can anyone tell me how I can extrapolate these to get an estimate of the median survival (with 95% confidence limits)?

    Many thanks!
    Attached Images

  17. #14
    Points: 40, Level: 1
    Level completed: 80%, Points required for next Level: 10

    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Survival Analysis with Interval Censored Data


    hi!!!
    i'm doing exactly same as yours!!

    glaucoma operations survival analysis...interval censoring...but my data is very raw. need to find left time and right time by myself...and also determine status

    don't know how to do it

+ Reply to Thread

           




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats