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
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
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
Ok finally did it..... so problem solved!
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
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.
SiBorg (03-10-2012)
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.Is there a reason you're using rep(1:51, each = 1) instead of just 1:51?
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.
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.
SiBorg (03-10-2012)
The first two lines is what I really wanted to do but didn't know how. Thank you very much Dason.
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.
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/
Does this work?
I haven't used survival in quite some time so I don't remember if that gives you what you want or not.Code:plot(mysurvfit) lines(mysurvfit2, col = "red")
I don't have emotions and sometimes that makes me very sad.
SiBorg (03-10-2012)
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.
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!
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
Tweet |