[R] question about val.surv in R
Frank Harrell
f.harrell at vanderbilt.edu
Sun May 8 16:17:08 CEST 2011
Please specify the package(s) you are using. In this case it should be rms.
val.surv is mainly for an out-of-sample validation, as it does not penalize
for overfitting. calibrate.cph is probably what you should be using.
To use val.surv in the fashion you are trying to use it, specify y=TRUE,
surv=TRUE to cph and specify the time point you are validating with the u
argument to val.surv (e.g., u=1 for 1 year survival probability validation).
Frank
yz wrote:
>
> Dear R users:
>
> I tried to use val.surv to give an internal validation of survival
> prediction model.
>
> I used the sample sources.
>
> # Generate failure times from an exponential distribution
> 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)
>
> # I use cph instead of psm in the example
> f <- cph(S ~ age + sex, y=TRUE)
> w <- val.surv(f)
>
> I got an error:
> Error in survreg.distributions[[fit$dist]] :
> attempt to select less than one element
>
> Could some one explain for me?
>
> Error in survreg.distributions[[fit$dist]] :
> attempt to select less than one element
>
>
> Error in survreg.distributions[[fit$dist]] :
> attempt to select less than one element
>
>
>
>
>
>
>
>
>
> *Yao Zhu*
> *Department of Urology
> Fudan University Shanghai Cancer Center
> Shanghai, China*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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/question-about-val-surv-in-R-tp3506666p3507015.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list