Skip to content

calibration curve for cph()

8 messages · array chip, Frank E Harrell Jr, David Winsemius

#
Build a prediction function using  'Function' that gets applied to set2. Calibrate and validate.
#
David Winsemius wrote:
-----
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.
#
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.harrell at vanderbilt.edu>
To: r-help at r-project.org
Cc: 
Sent: Tuesday, August 16, 2011 4:23 AM
Subject: Re: [R] calibration curve for cph()
David Winsemius wrote:
-----
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 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.
#
On Aug 16, 2011, at 1:57 PM, array chip wrote:

            
It is interesting that neither my mail client nor the archives show  
the code that was sent to nabble.

For posterity it was
require(rms)
?val.surv
Unable to reproduce. I get sensible output.  You may need to post  
sessionInfo(). Do you have all the dependencies installed? I noticed  
that even after rms was loaded with messages about also loading  
Hmisc,  survival, and splines, that there was a further message saying  
polspline was being loaded.
#
Oops, thank for reminding. I found that an in-house package interfered with rms package, which caused the error. 

Thanks David!

John



----- Original Message -----
From: David Winsemius <dwinsemius at comcast.net>
To: array chip <arrayprofile at yahoo.com>
Cc: Frank Harrell <f.harrell at vanderbilt.edu>; "r-help at r-project.org" <r-help at r-project.org>
Sent: Tuesday, August 16, 2011 11:27 AM
Subject: Re: [R] calibration curve for cph()
On Aug 16, 2011, at 1:57 PM, array chip wrote:

            
It is interesting that neither my mail client nor the archives show the code that was sent to nabble.

For posterity it was
require(rms)
?val.surv
Unable to reproduce. I get sensible output.? You may need to post sessionInfo(). Do you have all the dependencies installed? I noticed that even after rms was loaded with messages about also loading Hmisc,? survival, and splines, that there was a further message saying polspline was being loaded.
--david.
R version 2.13.1 RC (2011-07-03 r56263)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines?  stats? ?  graphics? grDevices utils? ?  datasets? methods?  base

other attached packages:
[1] polspline_1.1.5 rms_3.3-1? ? ?  Hmisc_3.8-3? ?  survival_2.36-9
[5] TTR_0.20-3? ? ? xts_0.8-0? ? ?  zoo_1.6-5? ? ?  sos_1.3-0
[9] brew_1.0-6? ? ? lattice_0.19-30

loaded via a namespace (and not attached):
[1] cluster_1.14.0 grid_2.13.1? ? tools_2.13.1
David Winsemius, MD
West Hartford, CT