Title: | NRI for Risk Prediction Models with Time to Event and Binary Response Data |
---|---|
Description: | Calculating the net reclassification improvement (NRI) for risk prediction models with time to event and binary data. |
Authors: | Eisuke Inoue |
Maintainer: | Eisuke Inoue <[email protected]> |
License: | GPL-2 |
Version: | 1.6 |
Built: | 2025-02-14 04:55:52 UTC |
Source: | https://github.com/cran/nricens |
This package provides the functions to estimate the net
reclassification improvement (NRI) for competing risk prediction
models with time to event and binary response data.
The NRI for binary response models can be calculated by nribin
,
and that for time to event models can be calculated by
nricens
.
The risk category based NRI and the risk difference based NRI are
provided by these functions.
Users can use several estimators for comparing time to event models.
Confidence intervals are calculated by the percentile bootstrap
method.
In this version, several types of input data are allowed to improve
user-friendliness and convenience.
Package: | nricens |
Type: | Package |
Version: | 1.6 |
Date: | 2018-5-30 |
License: | GPL-2 |
Eisuke Inoue <[email protected]>
Pencina MJ, D'Agostino RB, Steyerberg EW. Extensions of net reclassification improvement calculations to measure usefulness of new biomarkers. Statistics in Medicine 2011.
Uno H, Tian L, Cai T, Kohane IS, Wei LJ. A unified inference procedure for a class of measures to assess improvement in risk prediction systems with survival data, Statistics in Medicine 2012.
Hsu CH, Taylor JMG. A robust weighted Kaplan-Meier approach for data with dependent censoring using linear combinations of prognostic covariates, Statistics in Medicine 2010.
## consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## predciting the event of 'death' time = dat$time event = ifelse(dat$status==2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## fitting cox models mstd = coxph(Surv(time, event) ~ ., data.frame(time, event, z.std), x=TRUE) mnew = coxph(Surv(time, event) ~ ., data.frame(time, event, z.new), x=TRUE) ## Calculation of the risk category NRI at 2000 days nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, cut = c(0.2, 0.4), niter = 10) ## Next, consider binary prediction models library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## subjects censored before 2000 days are excluded dat = dat[ dat$time > 2000 | (dat$time < 2000 & dat$status == 2), ] ## predciting the event of 'death' before 2000 days event = ifelse(dat$time < 2000 & dat$status == 2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## glm fit (logistic model) mstd = glm(event ~ ., binomial(logit), data.frame(event, z.std), x=TRUE) mnew = glm(event ~ ., binomial(logit), data.frame(event, z.new), x=TRUE) ## Calculation of risk difference NRI nribin(mdl.std = mstd, mdl.new = mnew, cut = 0.02, niter = 0, updown = 'diff')
## consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## predciting the event of 'death' time = dat$time event = ifelse(dat$status==2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## fitting cox models mstd = coxph(Surv(time, event) ~ ., data.frame(time, event, z.std), x=TRUE) mnew = coxph(Surv(time, event) ~ ., data.frame(time, event, z.new), x=TRUE) ## Calculation of the risk category NRI at 2000 days nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, cut = c(0.2, 0.4), niter = 10) ## Next, consider binary prediction models library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## subjects censored before 2000 days are excluded dat = dat[ dat$time > 2000 | (dat$time < 2000 & dat$status == 2), ] ## predciting the event of 'death' before 2000 days event = ifelse(dat$time < 2000 & dat$status == 2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## glm fit (logistic model) mstd = glm(event ~ ., binomial(logit), data.frame(event, z.std), x=TRUE) mnew = glm(event ~ ., binomial(logit), data.frame(event, z.new), x=TRUE) ## Calculation of risk difference NRI nribin(mdl.std = mstd, mdl.new = mnew, cut = 0.02, niter = 0, updown = 'diff')
Internaly used function to categorize a continuous variable.
categorize(dat, threshold)
categorize(dat, threshold)
dat |
Numerical vector for a categorization. |
threshold |
Vector or scalar value(s) to determine the cutoff values for a categorization. |
This function estimates given covariates under the
Cox model.
get.risk.coxph(mdl, t0)
get.risk.coxph(mdl, t0)
mdl |
|
t0 |
Scalar value indicating a time to determine evnet/non-event ( |
This function estimates given covariates under the
parametric survival model.
get.risk.survreg(mdl, t0)
get.risk.survreg(mdl, t0)
mdl |
|
t0 |
Scalar value indicating a time to determine evnet/non-event ( |
This function estimates by the Kaplan-Meier
estimator.
should be given.
get.surv.km(time, event, t0, subs = NULL)
get.surv.km(time, event, t0, subs = NULL)
time |
Vector of follow up times. |
event |
Vector of event indicators, 1 for event of interest, 0 for censoring. |
t0 |
Scalar value indicating a time to determine evnet/non-event ( |
subs |
Vector of logical values to determine which subjects to be used for
a calculation. When this option is not specified
( |
UP
and DOWN
for the NRI calculation
Internaly used function to detemine subjects who belong to UP
and DOWN
.
get.uppdwn(time, event, objs, flag.mdl, flag.prd, flag.rsk, t0, updown, cut, get.risk, msg = FALSE)
get.uppdwn(time, event, objs, flag.mdl, flag.prd, flag.rsk, t0, updown, cut, get.risk, msg = FALSE)
time |
Vector of follow up times. |
event |
Vector of event indicators, 1 for event of interest, 0 for censoring. |
objs |
List of data. |
flag.mdl , flag.prd , flag.rsk
|
Logical values to determine the type of calculation based on the input data. |
t0 |
Scalar value indicating a time to determine evnet/non-event. |
updown |
Character to specify the method to determine |
cut |
Scalar or vector to specify the cutoff value(s) of predicted risks
for determining |
get.risk |
R function to calculate individual risks. |
msg |
Logical value to display computation process.
Setting |
UP
and DOWN
for the NRI calculation
Internaly used function to detemine subjects who belong to UP
and DOWN
.
get.uppdwn.bin(event, objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg = FALSE)
get.uppdwn.bin(event, objs, flag.mdl, flag.prd, flag.rsk, updown, cut, link, msg = FALSE)
event |
Vector of event indicators, 1 for event of interest, 0 for non-event. |
objs |
List of data. |
flag.mdl , flag.prd , flag.rsk
|
Logical values to determine the type of calculation based on the input data. |
updown |
Character to specify the method to determine |
cut |
Scalar or vector to specify the cutoff value(s) of predicted risks
for determining |
link |
Character to specify the link function for a glm fitting. |
msg |
Logical value to display computation process.
Setting |
This function estimates the NRI for competing risk prediction models
with binary response variable. glm
objects, predictors, and
predicted risks can be used as input data for the calculation.
The risk category based NRI and the risk difference based NRI can be
calculated.
The percentile bootstrap method is used for an interval estimation.
nribin(event = NULL, mdl.std = NULL, mdl.new = NULL, z.std = NULL, z.new = NULL, p.std = NULL, p.new = NULL, updown = "category", cut = NULL, link = "logit", niter = 1000, alpha = 0.05, msg = TRUE)
nribin(event = NULL, mdl.std = NULL, mdl.new = NULL, z.std = NULL, z.new = NULL, p.std = NULL, p.new = NULL, updown = "category", cut = NULL, link = "logit", niter = 1000, alpha = 0.05, msg = TRUE)
event |
Vector of event indicators, 1 for event of interest, 0 for non-event. |
mdl.std , mdl.new
|
|
z.std , z.new
|
Matrix of predictors for a standard and a new risk prediction model, respectively. Neither factor nor character nor missing values are allowed. |
p.std , p.new
|
Vector of predicted risks from a standard and a new prediction model, respectively. |
updown |
Character to specify the method to determine |
cut |
Scalar or vector values to specify the cutoff value(s) of predicted
risks for determining |
niter |
Scalar value to determine the number of bootstratp sampling. When
|
link |
Character to specify a link function for a glm fitting. |
alpha |
1-alpha confidence intervals are calcualted. |
msg |
Logical value to display computation process.
Setting |
Either one set of the following arguments should be specified for the
NRI calculation: (mdl.std
, mdl.new
);
(event
, z.std
, z.new
);
and (event
, p.std
, p.new
).
In the first set of the argument, (mdl.std
, mdl.new
),
fitted results are used for the NRI calculation.
event
, z.std
, and z.new
are extracted from fitted
result objects.
The variance of model parameters are accounted for an interval
estimation of the NRI.
When event
is specified in arguments, those specified is used
without extracting from glm
object.
In the second set of the argument, (event
, z.std
,
z.new
), a standard and a new prediction models are fitted
inside this function with specified link
.
The variance of model parameters are also accounted for an interval
estimation of the NRI.
In the third set of the argument, (event
, p.std
,
p.new
), predicted risks are used.
Since fit of prediction models are not conducted while in a bootstrap,
this can be used for a validation study by an external data source or
by a cross-validation.
For the risk category based NRI calculation, cutoff values of risk
category can be specified by cut
, which is a scalar for the
case of two risk categories and is a vector for the case of more than
two risk categories.
UP
and DOWN
are determined by the movement in risk
categories.
For the risk difference based NRI calculation, cutoff values of risk
difference can also be specified by cut
, where UP
and
DOWN
are defiend as and
, respectively.
and
are predicted individual risks
from a standard and a new prediction model, respectively, and
corresponds to
cut
.
The continuous NRI, which is the special version of the risk
difference based NRI, can be calculated by specifying both
updown = "diff"
and cut = 0
.
Interval estimation is based on the percentile bootstrap method.
Returns a list of the following items:
nri |
Point and interval estimates of the NRI and its components. |
mdl.std , mdl.new
|
Fitted |
z.std , z.new
|
Predictors of a standard and a new prediction model, respectively.
These items are provided when they are extracted from |
p.std , p.new
|
Predicted risks by a standard and a new prediction model, respectively. |
up , down
|
Logical values to show subjects who belong to |
rtab , rtab.case , rtab.ctrl
|
|
bootstrapsample |
Results of each bootstrap sample. |
## here consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## subjects censored before 2000 days are excluded dat = dat[ dat$time > 2000 | (dat$time < 2000 & dat$status == 2), ] ## predciting the event of 'death' before 2000 days event = ifelse(dat$time < 2000 & dat$status == 2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## glm fit (logistic model) mstd = glm(event ~ ., binomial(logit), data.frame(event, z.std), x=TRUE) mnew = glm(event ~ ., binomial(logit), data.frame(event, z.new), x=TRUE) ## predicted risk p.std = mstd$fitted.values p.new = mnew$fitted.values ## Calculation of risk difference NRI using ('mdl.std', 'mdl.std'). nribin(mdl.std = mstd, mdl.new = mnew, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk difference NRI using ('event', 'z.std', 'z.std'). nribin(event = event, z.std = z.std, z.new = z.new, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk difference NRI using ('event', 'p.std', 'p.std'). nribin(event = event, p.std = p.std, p.new = p.new, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk category NRI using ('mdl.std', 'mdl.std'). nribin(mdl.std = mstd, mdl.new = mnew, cut = c(0.2, 0.4), niter = 0, updown = 'category')
## here consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## subjects censored before 2000 days are excluded dat = dat[ dat$time > 2000 | (dat$time < 2000 & dat$status == 2), ] ## predciting the event of 'death' before 2000 days event = ifelse(dat$time < 2000 & dat$status == 2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## glm fit (logistic model) mstd = glm(event ~ ., binomial(logit), data.frame(event, z.std), x=TRUE) mnew = glm(event ~ ., binomial(logit), data.frame(event, z.new), x=TRUE) ## predicted risk p.std = mstd$fitted.values p.new = mnew$fitted.values ## Calculation of risk difference NRI using ('mdl.std', 'mdl.std'). nribin(mdl.std = mstd, mdl.new = mnew, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk difference NRI using ('event', 'z.std', 'z.std'). nribin(event = event, z.std = z.std, z.new = z.new, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk difference NRI using ('event', 'p.std', 'p.std'). nribin(event = event, p.std = p.std, p.new = p.new, cut = 0.02, niter = 0, updown = 'diff') ## Calculation of risk category NRI using ('mdl.std', 'mdl.std'). nribin(mdl.std = mstd, mdl.new = mnew, cut = c(0.2, 0.4), niter = 0, updown = 'category')
Internaly used function by nribin
.
In the comparison for binary models, it is possible to use directly
when UP
and DOWN
subjects are known.
nribin.count.main(event, upp, dwn)
nribin.count.main(event, upp, dwn)
event |
Vector of event indicators, 1 for event of interest, 0 for non-event. |
upp , dwn
|
Vector of logical values to determine subjects who belong to
|
This function estimates the NRI for competing risk prediction models
with time to event variable. coxph
object, survreg
object, predictors, and predicted risks can be used as input data for
the calculation.
The risk category based NRI and the risk difference based NRI can be
calculated.
Users can use several types of estimators to obtain point estimates of
the NRI and its components.
The percentile bootstrap method is used for an interval estimation.
nricens(time = NULL, event = NULL, mdl.std = NULL, mdl.new = NULL, z.std = NULL, z.new = NULL, p.std = NULL, p.new = NULL, t0 = NULL, updown = "category", cut = NULL, point.method = "km", niter = 1000, alpha = 0.05, msg = TRUE)
nricens(time = NULL, event = NULL, mdl.std = NULL, mdl.new = NULL, z.std = NULL, z.new = NULL, p.std = NULL, p.new = NULL, t0 = NULL, updown = "category", cut = NULL, point.method = "km", niter = 1000, alpha = 0.05, msg = TRUE)
time |
Vector of observed follow up times, |
event |
Vector of event indicators, 1 for event of interest, 0 for censoring. |
mdl.std , mdl.new
|
|
z.std , z.new
|
Matrix of predictors for a standard and a new risk prediction model, respectively. Neither factor nor character nor missing values are allowed. |
p.std , p.new
|
Vector of predicted risks from a standard and a new prediction model, respectively. |
t0 |
Scalar value indicating a time to determine evnet/non-event. |
updown |
Character to specify the method to determine |
cut |
Scalar or vector values to specify the cutoff value(s) of predicted
risks for determining |
point.method |
Character to determine an estimator for a point estimation.
When |
niter |
Scalar value to determine the number of bootstratp sampling. When
|
alpha |
1-alpha confidence interval is calcualted. |
msg |
Logical value to display computation process.
Setting |
Either one set of the following arguments should be specified for the
NRI calculation: (mdl.std
, mdl.new
);
(time
, event
, z.std
, z.new
);
and (time
, event
, p.std
, p.new
).
In the first set of the argument, (mdl.std
, mdl.new
),
fitted results by coxph
or survreg
are used for the NRI
calculation.
time
, event
, z.std
, and z.new
are
extracted from fitted result objects.
The variance of model parameters are accounted for an interval
estimation of the NRI.
When time
and event
are specified in arguments,
those specified are used without extracting from coxph
or
survreg
objects.
In the second set of the argument, (time
, event
,
z.std
, z.new
), a standard and a new prediction models
are fitted inside this function with time
, event
,
z.std
and z.new
.
The variance of model parameters are also accounted for an interval
estimation of the NRI.
In the third set of the argument, (time
, event
,
p.std
, p.new
), predicted risks are used.
Since fit of prediction models are not conducted while in a bootstrap,
this can be used for a validation study by an external data source or
by a cross-validation.
For the risk category based NRI calculation, cutoff values of risk
category can be specified by cut
, which is a scalar for the
case of two risk categories and is a vector for the case of more than
two risk categories.
UP
and DOWN
are determined by the movement in risk
categories.
For the risk difference based NRI calculation, cutoff values of risk
difference can also be specified by cut
, where UP
and
DOWN
are defiend as and
, respectively.
and
are predicted individual risks
from a standard and a new prediction model, respectively, and
corresponds to
cut
.
The continuous NRI, which is the special version of the risk
difference based NRI, can be calculated by specifying both
updown = "diff"
and cut = 0
.
Interval estimation is based on the percentile bootstrap method.
Returns a list of the following items:
nri |
Point and interval estimates of the NRI and its components. |
mdl.std , mdl.new
|
Fitted |
z.std , z.new
|
Predictors of a standard and a new prediction model, respectively.
These items are provided when they are extracted from |
p.std , p.new
|
Predicted risks by a standard and a new prediction model, respectively. |
up , down
|
Logical values to show subjects who belong to |
rtab , rtab.case , rtab.ctrl
|
|
bootstrapsample |
Results of each bootstrap sample. |
Pencina MJ, D'Agostino RB, Steyerberg EW. Extensions of net reclassification improvement calculations to measure usefulness of new biomarkers. Statistics in Medicine 2011.
Uno H, Tian L, Cai T, Kohane IS, Wei LJ. A unified inference procedure for a class of measures to assess improvement in risk prediction systems with survival data, Statistics in Medicine 2012.
Hsu CH, Taylor JMG. A robust weighted Kaplan-Meier approach for data with dependent censoring using linear combinations of prognostic covariates, Statistics in Medicine 2010.
## here consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## predciting the event of 'death' time = dat$time event = ifelse(dat$status==2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## coxph fit mstd = coxph(Surv(time,event) ~ ., data.frame(time,event,z.std), x=TRUE) mnew = coxph(Surv(time,event) ~ ., data.frame(time,event,z.new), x=TRUE) ## predicted risk at t0=2000 p.std = get.risk.coxph(mstd, t0=2000) p.new = get.risk.coxph(mnew, t0=2000) ## Calculation of risk category NRI ## by the KM estimator using ('mdl.std', 'mdl.std'). nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## by the KM estimator using ('time', 'event', 'z.std', 'z.std'). nricens(time = time, event = event, z.std = z.std, z.new = z.new, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## by the KM estimator using ('time','event','p.std','p.std'). nricens(time = time, event = event, p.std = p.std, p.new = p.new, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## Calculation of risk difference NRI by the KM estimator nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, updown = 'diff', cut = 0.05, niter = 0) ## Calculation of risk difference NRI by the IPW estimator nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, updown = 'diff', cut = 0.05, point.method = 'ipw', niter = 0)
## here consider pbc dataset in survival package as an example library(survival) dat = pbc[1:312,] dat$sex = ifelse(dat$sex=='f', 1, 0) ## predciting the event of 'death' time = dat$time event = ifelse(dat$status==2, 1, 0) ## standard prediction model: age, bilirubin, and albumin z.std = as.matrix(subset(dat, select = c(age, bili, albumin))) ## new prediction model: age, bilirubin, albumin, and protime z.new = as.matrix(subset(dat, select = c(age, bili, albumin, protime))) ## coxph fit mstd = coxph(Surv(time,event) ~ ., data.frame(time,event,z.std), x=TRUE) mnew = coxph(Surv(time,event) ~ ., data.frame(time,event,z.new), x=TRUE) ## predicted risk at t0=2000 p.std = get.risk.coxph(mstd, t0=2000) p.new = get.risk.coxph(mnew, t0=2000) ## Calculation of risk category NRI ## by the KM estimator using ('mdl.std', 'mdl.std'). nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## by the KM estimator using ('time', 'event', 'z.std', 'z.std'). nricens(time = time, event = event, z.std = z.std, z.new = z.new, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## by the KM estimator using ('time','event','p.std','p.std'). nricens(time = time, event = event, p.std = p.std, p.new = p.new, t0 = 2000, cut = c(0.2, 0.4), niter = 0) ## Calculation of risk difference NRI by the KM estimator nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, updown = 'diff', cut = 0.05, niter = 0) ## Calculation of risk difference NRI by the IPW estimator nricens(mdl.std = mstd, mdl.new = mnew, t0 = 2000, updown = 'diff', cut = 0.05, point.method = 'ipw', niter = 0)
Internaly used function by nricens
to provide the NRI estimator
by the IPW method.
In the comparison for time to event models, it is possible to use
directly when UP
and DOWN
subjects are known.
nricens.ipw.main(time, event, upp, dwn, t0)
nricens.ipw.main(time, event, upp, dwn, t0)
time |
Vector of follow up times. |
event |
Vector of event indicators, 1 for event of interest, 0 for censoring. |
upp , dwn
|
Vector of logical values to determine subjects who belong to
|
t0 |
Scalar value indicating a time to determine evnet/non-event. |
Internaly used function by nricens
to provide the NRI estimator
by the Kaplan-Meier(KM) method.
In the comparison for time to event models, it is possible to use
directly when UP
and DOWN
subjects are known.
nricens.km.main(time, event, upp, dwn, t0)
nricens.km.main(time, event, upp, dwn, t0)
time |
Vector of follow up times. |
event |
Vector of event indicators, 1 for event of interest, 0 for censoring. |
upp , dwn
|
Vectors of logical values to determine subjects who belong to
|
t0 |
Scalar value indicating a time to determine evnet/non-event. |