Concordance with a confidence interval, and comparing two risk scores
Source:R/metrics.R
concordance_index_ci.Rdconcordance_index_ci() gives Uno's weighted concordance (see concordance_index_ipcw()), or
with cause the competing-risks concordance of concordance_index_incidence(), with a standard
error from the infinitesimal jackknife. Each subject's influence is the derivative of the
estimate in that subject's case weight, with the censoring weights held fixed, and the variance
is the sum of the squared influences. The confidence interval is built on the logit scale (the
default), the log scale, or the original scale, then transformed back and kept within 0 and 1.
Usage
concordance_index_ci(
response,
risk,
cause = NULL,
tau = NULL,
conf_level = 0.95,
transform = c("logit", "log", "identity")
)
concordance_index_compare(
response,
risk_a,
risk_b,
cause = NULL,
tau = NULL,
conf_level = 0.95
)Arguments
- response
A right-censored
Surv()object or, withcause, a competing-risks one,Surv(time, event)witheventa factor whose first level means censored.- risk
A risk score for each subject, such as a Cox model's linear predictor or, with
cause, a predicted cumulative incidence. Higher scores mean earlier events.- cause
For competing risks, the cause, as a level of
eventor its number (1 for the first cause). The default,NULL, is the concordance for right-censored data.- tau
The truncation time. The default is the last event time (of the cause).
- conf_level
The confidence level, between 0 and 1. The default is
0.95.- transform
The scale of the confidence interval:
"logit"(the default),"log", or"identity".- risk_a, risk_b
The two risk scores compared by
concordance_index_compare().
Value
concordance_index_ci() gives a one-row data frame with estimate, std_error,
conf_low, conf_high, and n (the number of subjects). concordance_index_compare() gives
a one-row data frame with difference (the concordance of risk_a minus that of risk_b),
std_error, conf_low, conf_high, statistic, and the two-sided p_value.
Details
concordance_index_compare() tests whether two risk scores for the same subjects have the same
concordance. The standard error of the difference comes from the difference of the two scores'
influences, which accounts for the correlation between the estimates. The test is a Wald test,
and the confidence interval is on the original scale.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2),
age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68),
sex = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
)
one <- cox_ph(Surv(time, status) ~ age, data = lung)
two <- cox_ph(Surv(time, status) ~ age + sex, data = lung)
death <- Surv(lung$time, lung$status)
concordance_index_ci(death, risk = predict(two))
#> estimate std_error conf_low conf_high n
#> 1 0.6923077 0.07918389 0.5205793 0.8233915 12
concordance_index_compare(death, risk_a = predict(two), risk_b = predict(one))
#> difference std_error conf_low conf_high statistic p_value
#> 1 0.1307692 0.0954737 -0.05635578 0.3178942 1.369689 0.1707841