How to make survival object for Kaplan-Meier survival analysis in R
1
0
Entering edit mode
8.0 years ago
1769mkc ★ 1.2k

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 • 4.3k views
ADD COMMENT
0
Entering edit mode

enter image description here

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 ?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
8.0 years ago
Benn 8.3k

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.

ADD COMMENT
0
Entering edit mode

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 ?

ADD REPLY
0
Entering edit mode

Yes Im using survival library

ADD REPLY
0
Entering edit mode

You need per sample the age (in days) in your matrix, see an example here:

https://rstudio-pubs-static.s3.amazonaws.com/5588_72eb65bfbe0a4cb7b655d2eee0751584.html

e.g.

sample time
mouse1 12
mouse2 16
...
ADD REPLY
0
Entering edit mode

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?

ADD REPLY
2
Entering edit mode

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)
ADD REPLY
1
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2302 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6