On 12/13/06, Marco Chiarandini <marco at imada.sdu.dk>
wrote:> Dear all,
>
> I am trying to produce survfit plots in a trellis environment and I
> would like the plots to be logarithmic.
>
> I am trying this:
>
> print(Ecdf(~time | size*type, groups=alg,data=B,subscripts=TRUE,
> panel=function(x,groups,subscripts)
> {
> t <-
survfit(Surv(time[subscripts],event[subscripts])~groups[subscripts],data=B)
> panel.xyplot(t[1]$time,1-t[1]$ssurv,type="s",lty=2)
> panel.xyplot(t[2]$time,1-t[2]$ssurv,type="s",lty=2)
> },
> scale=list(log=TRUE)
> )
>
>
>
> but data are transformed in logarithm before being passed to the panel
> and hence the output of the function survfit is not the expected one.
>
> Is there a way to plot this correctly, ie, having first the survfit
> computed and then the plot, like in:
>
> plot(survfit(Surv(time,event)~groups,data=B),log=true)
Since you haven't bothered to follow the posting guide at all, it took
me a while to figure out that you live in that alternate R universe
created by Prof Harrell. Can't help you there, but in the standard
universe, things seem fairly simple:
library(survival)
fm <- survfit(Surv(time, status) ~ x, data=aml)
xyplot(surv ~ time, data = fm, type = "s",
groups = rep(names(strata), strata))
xyplot(surv ~ time, data = fm, type = "s",
groups = rep(names(strata), strata),
scales = list(log = TRUE))
xyplot(surv + lower + upper ~ time | rep(names(strata), strata),
data = fm, type = "s",
scales = list(y = list(log = TRUE)))
-Deepayan