Dear Frank,

Thanks for suggesting val.surv() function from rms package. It's exactly what I 
need. I tried the example on the help page and tweak towards to my situation, 
but got an error message. Could you suggestion what went wrong?

library(rms)
set.seed(123)              # so can reproduce results
n <- 1000
age <- 50 + 12*rnorm(n)
sex <- factor(sample(c('Male','Female'), n, rep=TRUE, prob=c(.6, .4)))
cens <- 15*runif(n)
h <- .02*exp(.04*(age-50)+.8*(sex=='Female'))
t <- -log(runif(n))/h
units(t) <- 'Year'
label(t) <- 'Time to Event'
ev <- ifelse(t <= cens, 1, 0)
t <- pmin(t, cens)
S <- Surv(t, ev)



f <- cph(S ~ age + sex, x=TRUE, y=TRUE)
val.surv(f, newdata=data.frame(age,sex), S=S, u=5)  ## pretend the same 
training data as the independent dataset

Error in val.surv(f, newdata = data.frame(age, sex), S = S, u = 5) : 
  unused argument(s) (u = 5)


Many thanks

John










----- Original Message -----
From: Frank Harrell <f.harr...@vanderbilt.edu>
To: r-help@r-project.org
Cc: 
Sent: Tuesday, August 16, 2011 4:23 AM
Subject: Re: [R] calibration curve for cph()



David Winsemius wrote:
> 
> A combination of Predict (your newdata), cut2, and the plotting function
> of your choice ought to suffice. But thought that cross-validation was an
> option. Not at console at the moment (just off airplane.)
> 
> Sent from my iPhone
> 
> On Aug 15, 2011, at 5:26 PM, array chip &lt;arrayprof...@yahoo.com&gt;
> wrote:
> 
>> is there a R function that produces calibration curve on an independetn
>> data automatically, just like what calibrate() does on the training data
>> itself?
>> 
>> Thanks
>> 
>> John
>> 
>> From: Comcast &lt;dwinsem...@comcast.net&gt;
>> To: array chip &lt;arrayprof...@yahoo.com&gt;
>> Cc: "r-help@r-project.org" &lt;r-help@r-project.org&gt;
>> Sent: Monday, August 15, 2011 2:04 PM
>> Subject: Re: [R] calibration curve for cph()
>> 
>> Build a prediction function using  'Function' that gets applied to set2.
>> Calibrate and validate.
>> 
>> -- 
>> David
>> 
>> Sent from my iPhone
>> 
>> On Aug 15, 2011, at 11:31 AM, array chip &lt;arrayprof...@yahoo.com&gt;
>> wrote:
>> 
>> > Hi, the calibrate.cph() function in rms package generate calibration
>> curve for Cox model on the same dataset where the model was derived using
>> bootstrapping or cross-validation. If I have the model built on dataset
>> 1, and now I want to produce a calibration curve for this model on an
>> independent dataset 2, how can I do that?
>> > 
>> > Thanks
>> > 
>> > John
>> > 
>> >    [[alternative HTML version deleted]]
>> > 
>> > ______________________________________________
>> > R-help@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.
>> 
>> 
> 
>     [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@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/calibration-curve-for-cph-tp3745328p3746931.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to