nribin: NRI for binary models

Description Usage Arguments Details Value Examples

Description

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.

Usage

1
2
3
4
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)
       

Arguments

event

Vector of event indicators, 1 for event of interest, 0 for non-event.

mdl.std, mdl.new

glm objects corresponding to a standard and a new risk prediction models, respectively. Since predictors are extracted from these objects, x=TRUE is required for a glm fitting.

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 UP and DOWN. When "category" is specified (by default), the risk category based NRI is calculated. When "diff" is specified, the risk difference based NRI is calculated.

cut

Scalar or vector values to specify the cutoff value(s) of predicted risks for determining UP and DOWN. For the risk category based NRI (updown = "category"), this option corresponds to cutoff value(s) of risk categories. For the risk difference based NRI (updown = "diff"), this option corresponds to a cutoff value of a risk difference (only scalar is allowed).

niter

Scalar value to determine the number of bootstratp sampling. When 0 is specified, an interval estimation is skipped.

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 FALSE leads silent execution.

Details

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 p_{new} - p_{standard} > δ and p_{standard} - p_{new} > δ, respectively. p_{standard} and p_{new} 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.

Value

Returns a list of the following items:

nri

Point and interval estimates of the NRI and its components.

mdl.std, mdl.new

Fitted glm objects corresponding to a standard and a new prediction model, respectively. These items are provided when prediction models are fitted inside this function. Otherwise NULL.

z.std, z.new

Predictors of a standard and a new prediction model, respectively. These items are provided when they are extracted from mdl.std and mdl.new. Otherwise NULL.

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 UP and DOWN, respectively.

rtab, rtab.case, rtab.ctrl

table objects corresponding to reclassification tables for all, case, and control subjects, respectively. These items are provided only when the risk category based NRI is calculated and msg = TRUE.

bootstrapsample

Results of each bootstrap sample.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## 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')

Example output

Loading required package: survival

UP and DOWN calculation:
  #of total, case, and control subjects at t0:  232 88 144
  #of subjects with 'p.new - p.std > cut' for all, case, control: 34 17 17
  #of subjects with 'p.std - p.new < cut' for all, case, control: 36 13 23

NRI estimation:
Point estimates:
                Estimate
NRI           0.04310345
NRI+          0.01724138
NRI-          0.02586207
Pr(Up|Case)   0.07327586
Pr(Down|Case) 0.05603448
Pr(Down|Ctrl) 0.09913793
Pr(Up|Ctrl)   0.07327586

STANDARD prediction model:
               Estimate Std. Error    z value     Pr(>|z|)
(Intercept)  0.98927136 2.20809035  0.4480212 6.541379e-01
age          0.07128234 0.01988079  3.5854876 3.364490e-04
bili         0.61686651 0.10992947  5.6114755 2.006087e-08
albumin     -1.95859156 0.53031693 -3.6932473 2.214085e-04

NEW prediction model:
               Estimate Std. Error    z value     Pr(>|z|)
(Intercept) -1.16682234 2.92204889 -0.3993165 6.896600e-01
age          0.06659224 0.02032242  3.2767864 1.049958e-03
bili         0.59995139 0.11022521  5.4429600 5.240243e-08
albumin     -1.88620553 0.53144647 -3.5491919 3.864153e-04
protime      0.20127560 0.18388726  1.0945598 2.737095e-01

UP and DOWN calculation:
  #of total, case, and control subjects at t0:  232 88 144
  #of subjects with 'p.new - p.std > cut' for all, case, control: 34 17 17
  #of subjects with 'p.std - p.new < cut' for all, case, control: 36 13 23

NRI estimation:
Point estimates:
                Estimate
NRI           0.04310345
NRI+          0.01724138
NRI-          0.02586207
Pr(Up|Case)   0.07327586
Pr(Down|Case) 0.05603448
Pr(Down|Ctrl) 0.09913793
Pr(Up|Ctrl)   0.07327586

UP and DOWN calculation:
  #of total, case, and control subjects at t0:  232 88 144
  #of subjects with 'p.new - p.std > cut' for all, case, control: 34 17 17
  #of subjects with 'p.std - p.new < cut' for all, case, control: 36 13 23

NRI estimation:
Point estimates:
                Estimate
NRI           0.04310345
NRI+          0.01724138
NRI-          0.02586207
Pr(Up|Case)   0.07327586
Pr(Down|Case) 0.05603448
Pr(Down|Ctrl) 0.09913793
Pr(Up|Ctrl)   0.07327586

UP and DOWN calculation:
  #of total, case, and control subjects at t0:  232 88 144

  Reclassification Table for all subjects:
        New
Standard < 0.2 < 0.4 >= 0.4
  < 0.2    110     3      0
  < 0.4      3    30      0
  >= 0.4     0     2     84

  Reclassification Table for case:
        New
Standard < 0.2 < 0.4 >= 0.4
  < 0.2      7     0      0
  < 0.4      0     8      0
  >= 0.4     0     2     71

  Reclassification Table for control:
        New
Standard < 0.2 < 0.4 >= 0.4
  < 0.2    103     3      0
  < 0.4      3    22      0
  >= 0.4     0     0     13

NRI estimation:
Point estimates:
                 Estimate
NRI           -0.00862069
NRI+          -0.00862069
NRI-           0.00000000
Pr(Up|Case)    0.00000000
Pr(Down|Case)  0.00862069
Pr(Down|Ctrl)  0.01293103
Pr(Up|Ctrl)    0.01293103

nricens documentation built on May 2, 2019, 6:01 a.m.