This is the version of the validate
function specific to models
fitted with cph
or psm
. Also included is a small
function dxy.cens
that retrieves survival
package's
concordancefit
function. This allows for incredibly fast
computation of dxy.cens
negates y
is a
left-censored Surv
object, times are negated and a
right-censored object is created, then
# fit <- cph(formula=Surv(ftime,event) ~ terms, x=TRUE, y=TRUE, \dots)
# S3 method for cph
validate(fit, method="boot", B=40, bw=FALSE, rule="aic",
type="residual", sls=.05, aics=0, force=NULL, estimates=TRUE,
pr=FALSE, dxy=TRUE, u, tol=1e-9, ...)# S3 method for psm
validate(fit, method="boot",B=40,
bw=FALSE, rule="aic", type="residual", sls=.05, aics=0,
force=NULL, estimates=TRUE, pr=FALSE,
dxy=TRUE, tol=1e-12, rel.tolerance=1e-5, maxiter=15, ...)
dxy.cens(x, y, type=c('time','hazard'))
matrix with rows corresponding to
The values corresponding to the row
a fit derived cph
. The options x=TRUE
and y=TRUE
must have been specified. If the model contains any stratification factors
and dxy=TRUE,
the options surv=TRUE
and time.inc=u
must also have been given,
where u
is the same value of u
given to validate
.
see validate
number of repetitions. For method="crossvalidation"
, is the
number of groups of omitted observations.
TRUE
to do fast step-down using the fastbw
function,
for both the overall model and for each repetition. fastbw
keeps parameters together that represent the same factor.
Applies if bw=TRUE
. "aic"
to use Akaike's information criterion as a
stopping rule (i.e., a factor is deleted if the "p"
to use
"residual"
or "individual"
- stopping rule is for
individual factors or for the residual dxy.cens
, specify
type="hazard"
if x
is on the hazard or cumulative
hazard (or their logs) scale, causing negation of the correlation index.
significance level for a factor to be kept in a model, or for judging the
residual
cutoff on AIC when rule="aic"
.
see fastbw
see print.fastbw
TRUE
to print results of each repetition
see validate
or predab.resample
set to TRUE
to validate Somers' dxy.cens
, which is fast until n > 500,000. Uses the
survival
package's concordancefit
service
function for concordance
.
must be specified if the model has any stratification factors and
dxy=TRUE
.
In that case, strata are not included in t=u
are
correlated with observed survival times. Does not apply to
validate.psm
.
a numeric vector
a Surv
object that may be uncensored or
right-censored
prints a summary, and optionally statistics for each re-fit (if
pr=TRUE
)
Frank Harrell
Department of Biostatistics, Vanderbilt University
fh@fharrell.com
Statistics validated include the Nagelkerke predab.resample
for the list of resampling methods.
validate
, predab.resample
,
fastbw
, rms
, rms.trans
,
calibrate
, rcorr.cens
,
cph
, survival-internal
,
gIndex
, concordancefit
require(survival)
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
e <- ifelse(dt <= cens,1,0)
dt <- pmin(dt, cens)
units(dt) <- "Year"
S <- Surv(dt,e)
f <- cph(S ~ age*sex, x=TRUE, y=TRUE)
# Validate full model fit
validate(f, B=10) # normally B=150
# Validate a model with stratification. Dxy is the only
# discrimination measure for such models, by Dxy requires
# one to choose a single time at which to predict S(t|X)
f <- cph(S ~ rcs(age)*strat(sex),
x=TRUE, y=TRUE, surv=TRUE, time.inc=2)
validate(f, u=2, B=10) # normally B=150
# Note u=time.inc
Run the code above in your browser using DataLab