Description Usage Arguments Details Author(s) Examples
View source: R/get_internal_validation.R
This function allows you to generate a Harrell's C-index of internal validation for a Cox PH model.
1 | get.internal.valid(formula, TR.data, B.num = 200, seed = 2019)
|
formula |
a formula used to specify a Cox PH model, see cph function. |
TR.data |
the name of a data frame containing all needed variables, used as training dataset. |
B.num |
a number of repetitions for bootstrap. Defaults to 150 |
seed |
a single value, interpreted as an integer, or NULL |
Returns C.index, a value of Harrell's C-index. C index is calculated from Dxy.
The relation between Dxy and C-index is Dxy=2*(C-0.5).
Xi "Ada" Wang
Ph.D. Student of Biostatistics
Penn State College of Medicine
xzw149@psu.edu
1 2 3 4 5 6 7 8 9 10 | n <- 500
set.seed(2019)
var1 <- 30 + 5*rnorm(n)
var2 <- factor(sample(c("White","Black"),n,rep=TRUE,prob=c(.3,.7)))
hazard <- .1*exp(.2*(var1-30)+.5*(var2=="Black"))
time_to_event <- -log(runif(n))/hazard
cens <- 15*runif(n)
censor <- ifelse(time_to_event <= cens,1,0)
TR <- data.frame(time_to_event = time_to_event,censor=censor, var1 = var1, var2= var2)
get.internal.valid(formula = Surv(time_to_event,censor) ~ var1 + var2,TR,B.num=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.