This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to make survival object for Kaplan-Meier survival analysis in R

So I have a study of 6 mice who are infected with plasmodium over a course of 7 days, I start with day five which is after checking the infection level ,and the first mice dies at day 12 ,second mice at day 16,third mice at day 9,fourth mice at day 9 as well ,fifth mice at dies at day 11,the sixth mice dies at day 11.

So now I have to plot this data in R ,can anyone let me know how to do that I see I have to construct a survival object Im not sure how its being done .Please let know how to do that?

I know how to do from the sample data Im not sure how these survival objects are being created ? Please help

r

enter image description here

so this is my data the number of days in the above and the number of subjects are 6

Have you tried googling for guidelines? I find multiple hits for Kaplan-Meier survival analysis in R

Yes I did but I cannot figure how they are making this " my.events <-c(1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,0,0)" I mean this with respect to the time or the days to death ?

isn't it with respect to live/dead status at the end of the experiment?

yes with respect to live and dead but my problem is how do I create the survival object? with my data

1 answer

If you want to use the "survival" library, you'll need to score the lengths of life of your mice first (so mouse # 1, 12 days, #2, 16 days, etc.). Then follow the guidelines for the survival package, there are (like @WouterDeCoster says) many tutorials on Google.

Yes I did but I cannot figure how they are making this

" my.events <-c(1,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,0,0)" I mean this with respect to the time or the days to death ?

Yes Im using survival library

yes i get it but what about the events data when the mouse dies how the 0 and 1 are decided what frequency can you let know?

At the end they all die, right?

library(survival)

mouse <- c(1,2,3,4,5,6)
time <- c(12,16,9,9,11,11)
status <- c(1,1,1,1,1,1)
m <- as.data.frame(cbind(mouse,time,status))
m$SurvObj <- with(m, Surv(time, status == 1))
m
  mouse time status SurvObj
1     1   12      1     12 
2     2   16      1     16 
3     3    9      1      9 
4     4    9      1      9 
5     5   11      1     11 
6     6   11      1     11 
km.as.one <- survfit(SurvObj ~ 1, data = m, conf.type = "log-log")
km.as.one
Call: survfit(formula = SurvObj ~ 1, data = m, conf.type = "log-log")

      n  events  median 0.95LCL 0.95UCL 
      6       6      11       9      NA 
plot(km.as.one)

thank you very much ....Im glad you helped me...

Log in to answer this question.