get.internal.cal: Internal Calibration of Cox PH model

Description Usage Arguments Details Author(s) Examples

View source: R/get_internal_calibrarion.R

Description

This function allows you to generate an internal calibration plot of a Cox PH model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get.internal.cal(
  formula,
  TR.data,
  time,
  fig.name,
  fig.title,
  fig.width = 800,
  fig.height = 700,
  quality = 300,
  res = 100,
  B.num = 150,
  seed = 2019
)

Arguments

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.

time

a single value to specify the timepoint you are interested in for calibration.

fig.name

a string for the name of the calibration plot.

fig.title

a string for the title of the figure

fig.width

a number of width of the calibration plot. Defaults to 800

fig.height

a number of height of the calibration plot. Defaults to 700

quality

the ‘quality’ of the JPEG image, as a percentage. Smaller values will give more compression but also more degradation of the image. Defaults to 300

res

The nominal resolution in ppi which will be recorded in the bitmap file, is a positive integer. Defaults to 100

B.num

a number of repetitions for bootstrap. Defaults to 150

seed

a single value, interpreted as an integer, or NULL

Details

For other parameters in rms::calibrate, use default setting.

In cph function, surv=TRUE and time.inc=u were specified to make a calibration plot.

Author(s)

Xi "Ada" Wang

Ph.D. Student of Biostatistics

Penn State College of Medicine

xzw149@psu.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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.cal(formula = Surv(time_to_event,censor) ~ var1 + var2,
                  TR.data = TR,time = 12,fig.name="name", fig.title='Survival_Plot')

ccwangxi/nomovalidation documentation built on Feb. 14, 2020, 9:21 a.m.