bethatkinson / rpart

Recursive Partitioning and Regression Trees
43 stars 23 forks source link

Error in get(paste("rpart", method, sep = "."), envir = environment())(Y, : Observation time must be > 0 #24

Closed jgarces02 closed 3 years ago

jgarces02 commented 3 years ago

Dear @bethatkinson,

First, first things: thanks a lot for this useful package. My data has this structure...

structure(list(c(20, 24, 78, 8, 73, 77, 75, 73, 73, 28, 74, 75, 
52, 76, 73, 74, 29, 72, 75, 72, 22, 12, 3, 47, 62, 9, 74, 73, 
3, 72, 36, 71, 38, 71, 23, 71, 40, 28, 25, 70, 68, 73, 29, 0, 
16, 70, 72, 73, 73, 69, 70, 59, 72, 48, 73, 73, 57, 62, 72, 32, 
70, 70, 5, 69, 70, 70, 18, 67, 70, 71, 5, 53, 26, 55, 69, 52, 
27, 67, 69, 9, 70, 67, 35, 9, 55, 36, 59, 66, 46, 25, 71, 7, 
30, 66, 0, 61, 68, 49, 66, 70), c(1, 1, 0, 1, 0, 0, 0, 1, 0, 
1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 
1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 
1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 
1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 
0, 1, 1, 0, 1, 0, 0), structure(c(3L, 3L, 2L, 4L, 2L, 2L, 4L, 
2L, 2L, 3L, 4L, 3L, 2L, 2L, 3L, 2L, 4L, 2L, 3L, 2L, 2L, 2L, 2L, 
3L, 3L, 3L, 3L, 4L, 3L, 1L, 4L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 
1L, 3L, 1L, 2L, 3L, 4L, 3L, 3L, 3L, 1L, 3L, 2L, 4L, 2L, 3L, 3L, 
1L, 3L, 4L, 3L, 4L, 1L,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1", "2", "3"), class = "factor"), structure(c(1L, 
2L, 1L, 2L, NA, NA, 1L, 1L, 1L, 1L, 2L, 1L, 1L, NA, 1L, 1L, 2L, 
NA, NA, NA, 1L, 2L, NA, 1L, 1L, 2L, NA, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, NA, 1L, 1L, 2L, NA, 1L, 2L, NA, NA, 2L, 1L, 1L, 1L, 2L, 2L, 
NA, NA, 1L, 1L, 1L, 1L, 1L, NA, 1L, 2L, 1L, NA, NA, 1L, 1L, 2L, 
1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, NA, 1L, 
1L, 1L, 1L, 2L, NA, 2L, 1L, 1L, NA, 1L, 1L, 2L, 1L, 1L, 1L, NA, 
2L, 1L, NA), .Label = c("0", "1"), class = "factor")), .Names = c("PFS", 
"PFS_c", "score", "Rscore", "grisk", NA), row.names = c(NA, 100L
), class = "data.frame")

... and I'm running rpart (the last version) with this code (and subsequent error):

>tr <- rpart(Surv(PFS, PFS_c) ~ score + Rscore + grisk, data = df, method = "exp", control = rpart.control(cp = 0.001))
Error in get(paste("rpart", method, sep = "."), envir = environment())(Y,  : 
  Observation time must be > 0

I've seen this error could be coming from poisson method but I'd expect that, because I'm adding a formula with Surv(time... and specifying method = "exp"... could you help me, please? Am I missing something?

Thanks in advance.

bethatkinson commented 3 years ago

You have 2 times that are 0. If you add .5 to those 2 subjects it will fix the analysis issue.


From: jgarces notifications@github.com Sent: Wednesday, December 9, 2020 6:38 AM To: bethatkinson/rpart rpart@noreply.github.com Cc: Atkinson, Elizabeth J. (Beth), M.S. atkinson@mayo.edu; Mention mention@noreply.github.com Subject: [EXTERNAL] [bethatkinson/rpart] Error in get(paste("rpart", method, sep = "."), envir = environment())(Y, : Observation time must be > 0 (#24)

Dear @bethatkinsonhttps://github.com/bethatkinson,

First, first things: thanks a lot for this useful package. My data has this structure...

structure(list(c(20, 24, 78, 8, 73, 77, 75, 73, 73, 28, 74, 75, 52, 76, 73, 74, 29, 72, 75, 72, 22, 12, 3, 47, 62, 9, 74, 73, 3, 72, 36, 71, 38, 71, 23, 71, 40, 28, 25, 70, 68, 73, 29, 0, 16, 70, 72, 73, 73, 69, 70, 59, 72, 48, 73, 73, 57, 62, 72, 32, 70, 70, 5, 69, 70, 70, 18, 67, 70, 71, 5, 53, 26, 55, 69, 52, 27, 67, 69, 9, 70, 67, 35, 9, 55, 36, 59, 66, 46, 25, 71, 7, 30, 66, 0, 61, 68, 49, 66, 70), c(1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0), structure(c(3L, 3L, 2L, 4L, 2L, 2L, 4L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 3L, 2L, 4L, 2L, 3L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 3L, 1L, 4L, 2L, 3L, 3L, 3L, 2L, 3L, 3L, 3L, 1L, 3L, 1L, 2L, 3L, 4L, 3L, 3L, 3L, 1L, 3L, 2L, 4L, 2L, 3L, 3L, 1L, 3L, 4L, 3L, 4L, 1L, 1L, 3L, 1L, 2L, 3L, 4L, 2L, 2L, 1L, 3L, 3L, 4L, 3L, 2L, 3L, 2L, 2L, 3L, 2L, 2L, 1L, 2L, 1L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 3L, 3L, 3L, 3L, 4L, 2L, 3L), .Label = c("0", "1", "2", "3"), class = "factor"), structure(c(2L, 2L, 1L, 2L, 2L, NA, 2L,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, NA, 1L, 2L, 1L, NA, NA, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, NA, 1L, 1L, 1L, 1L, 2L, NA, 2L, 1L, 1L, NA, 1L, 1L, 2L, 1L, 1L, 1L, NA, 2L, 1L, NA), .Label = c("0", "1"), class = "factor")), .Names = c("PFS", "PFS_c", "score", "Rscore", "grisk", NA), row.names = c(NA, 100L ), class = "data.frame")

... and I'm running rpart (the last version) with this code (and subsequent error):

tr <- rpart(Surv(PFS, PFS_c) ~ score + Rscore + grisk, data = df, method = "exp", control = rpart.control(cp = 0.001)) Error in get(paste("rpart", method, sep = "."), envir = environment())(Y, : Observation time must be > 0

I've seen this error could be coming from poisson method but I'd expect that, because I'm adding a formula with Surv(time... and specifying method = "exp"... could you help me, please? Am I missing something?

Thanks in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/bethatkinson/rpart/issues/24, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWQG573MBINWJ6YSVWFSTDST5VV3ANCNFSM4UTNV5QA.

jgarces02 commented 3 years ago

Definitely... sorry for so silly error and thanks a lot for your help!