[R] survplot() for cph(): Design vs rms
Frank Harrell
f.harrell at vanderbilt.edu
Fri Aug 26 01:33:50 CEST 2011
http://biostat.mc.vanderbilt.edu/Rrms shows differences between Design and
rms
Frank
array chip wrote:
>
> Thank you David. The plot from Design package will draw a plot of survival
> probability at 5 years (in my example) versus different age. I will look
> into Predict() in rms package to see how this can be done.
>
>
> John
>
>
>
>
>
>
> ----- Original Message -----
> From: David Winsemius <dwinsemius at comcast.net>
> To: array chip <arrayprofile at yahoo.com>
> Cc: "r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch>
> Sent: Thursday, August 25, 2011 3:15 PM
> Subject: Re: [R] survplot() for cph(): Design vs rms
>
>
> On Aug 25, 2011, at 5:11 PM, array chip wrote:
>
>> Hi, in Design package, a plot of survival probability vs. a covariate can
>> be generated by survplot() on a cph object using the folliowing code:
>>
>> n <- 1000
>> set.seed(731)
>> age <- 50 + 12*rnorm(n)
>> label(age) <- "Age"
>> sex <- factor(sample(c('male','female'), n, TRUE))
>> cens <- 15*runif(n)
>> h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
>> dt <- -log(runif(n))/h
>> label(dt) <- 'Follow-up Time'
>> e <- ifelse(dt <= cens,1,0)
>> dt <- pmin(dt, cens)
>> units(dt) <- "Year"
>> dd <- datadist(age, sex)
>> options(datadist='dd')
>> S <- Surv(dt,e)
>>
>>
>> library(Design)
>>
>> f <- cph(S ~ age, surv=TRUE,x=T,y=T)
>> plot(f,age=NA,time=5)
>>
>> But the same code won't work if I used rms package:
>>
>> detach(package:Design)
>> library(rms)
>>
>> f <- cph(S ~ age, surv=TRUE,x=T,y=T)
>>
>> plot(f,age=NA,time=5)
>> Error in xy.coords(x, y, xlabel, ylabel, log) :
>> 'x' and 'y' lengths differ
>>
>>
>> Is there a way to plot the same graph using rms package.
>
> I don't remember what that would have done in Design and you have not
> explained what you expected. You should read the rms help page for cph and
> walk through the examples where ht euse of the Predict function is
> illustrated. The plotting support for Predict objects is excellent.
>
>
>> I like to use Frank Harrell's new package rms and try to avoid using old
>> Design package.
>>
>> Thanks
>>
>> John
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/survplot-for-cph-Design-vs-rms-tp3769430p3769683.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list