cutoff for mean cumulative function plot not working in mcf

34 views Asked by At

For my own dataset, I have been able to create cutoff for an MCF plot by using the control=list(to=1000) parameter inside an mcf plot from the reda package

However for some reason it doesn't work anymore.

library(reReg)
library(ggplot2)
library(frailtypack)
data(readmission, package = "frailtypack")
readmission <- subset(readmission, !(id %in% c(60, 109, 280)))


mcf0 <- mcf(Recur(t.start %2% t.stop, id, event, death) ~ sex
  , data = readmission,control=list(to=1000))
mcf0


p <- plot(mcf0, conf.int = TRUE,control=list(to=1000)) + theme_bw(base_size = 20)
print(p)

The desired plot output is one where there is a cutoff at 1000 in the x variable time. enter image description here

Reading from the mcf function, it seems there are formula and rateReg objects, and I have no idea if that makes a difference. Thanks

1

There are 1 answers

0
stefan On

Don't know the packages you are using but as the result is a ggplot you could set the displayed range via the xlim argument of coord_cartesian where I also added expand=FALSE to remove the default expansion of the scale:

library(reReg)
library(ggplot2)
library(frailtypack)

data(readmission, package = "frailtypack")
readmission <- subset(readmission, !(id %in% c(60, 109, 280)))

mcf0 <- mcf(Recur(t.start %2% t.stop, id, event, death) ~ sex,
  data = readmission, control = list(to = 1000)
)

plot(mcf0, conf.int = TRUE, control = list(to = 1000)) + 
  theme_bw(base_size = 20) +
  coord_cartesian(xlim = c(0, 1000), expand = FALSE)