brierScore: Brier Score Calculation

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/DiscSurvEvaluation.R

Description

Computes the brier score of each person based on a generalized, linear model with cross validation.

Usage

1
2
brierScore(dataSet, trainIndices, survModelFormula, 
linkFunc = "logit", censColumn, idColumn = NULL)

Arguments

dataSet

Original data in short format. Must be of class "data.frame".

trainIndices

Must be a list of indices used for training data sets. E. g. if a 10-fold cross validation should be conducted, then the list should have length 10 and in each element a integer vector of training indices.

survModelFormula

Gives the specified relationship of discrete response and covariates. The formula is designed, that the intercepts for the time dependent base line hazards are always included. Therefore only covariates should be given in this formula. This argument is required to be of class "formula".

linkFunc

Specifies the desired link function in use of generalized, linear models.

censColumn

Gives the column name of the event indicator (1=observed, 0=censored). Must be of type "character".

idColumn

Gives the column name of the identification number of each person. The argument must be of type "character". Default NULL means, that each row equals one person (no repeated measurements).

Details

At normal circumstances a covariate free model for the censoring weights is sufficient.

Value

Numeric vector of brier scores for each person in the original data.

Note

It is assumed that all time points up to the last interval [a_q, Inf) are available in short format. If not already present, these can be added manually.

Author(s)

Thomas Welchowski [email protected]

Matthias Schmid [email protected]

See Also

adjDevResid, devResid, glm, predErrDiscShort

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Example with cross validation and unemployment data 
library(Ecdat)
library(caret)
data(UnempDur)
summary(UnempDur$spell)

# Extract subset of data
set.seed(635)
IDsample <- sample(1:dim(UnempDur)[1], 100)
UnempDurSubset <- UnempDur [IDsample, ]
head(UnempDurSubset)
range(UnempDurSubset$spell)
set.seed(7550)
CVfolds <- createFolds (y=UnempDurSubset$spell, returnTrain=TRUE, k=2)

# Calculate brier score
tryBrierScore <- brierScore (dataSet=UnempDurSubset, trainIndices=CVfolds, 
survModelFormula=spell ~ age + logwage, linkFunc="logit", 
censColumn="censor1", idColumn=NULL)
tryBrierScore

Example output

Loading required package: Ecfun

Attaching package: 'Ecfun'

The following object is masked from 'package:base':

    sign


Attaching package: 'Ecdat'

The following object is masked from 'package:datasets':

    Orange

Loading required package: lattice
Loading required package: ggplot2
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
  1.000   2.000   5.000   6.248   9.000  28.000 
     spell censor1 censor2 censor3 censor4 age  ui reprate disrate logwage
667      1       1       0       0       0  28  no   0.406   0.120 5.28827
1141     6       0       0       0       1  25 yes   0.490   0.245 5.56068
825      9       0       0       0       1  34 yes   0.500   0.025 5.06259
1441     3       0       0       0       0  23  no   0.369   0.071 5.89715
2038     3       1       0       0       0  22 yes   0.600   0.120 5.29832
1489     3       1       0       0       0  55  no   0.245   0.061 6.25575
     tenure
667      10
1141      6
825       1
1441      0
2038      1
1489      0
[1]  1 19
 [1] 0.14957015 0.75540594 0.65150910 0.62908327 0.35315206 0.59896853
 [7] 0.22286414 0.79170502 0.34835384 0.08769290 0.49255577 0.40261514
[13] 0.11382781 0.63669017 0.16225390 0.32022062 0.23664607 0.48478533
[19] 0.33250172 0.52306599 0.15509673 0.06852902 0.00000000 0.42674998
[25] 1.08287901 0.70829420 1.02536865 0.23444738 0.06560195 0.23093910
[31] 1.19031983 0.23260431 0.05462755 0.11423947 0.64956557 0.07616005
[37] 0.71606107 0.19679355 0.00000000 0.86947952 0.08638102 0.62649174
[43] 1.37707992 0.31107585 0.87148908 1.30644946 0.26257624 0.33526568
[49] 0.62172160 0.31387751

discSurv documentation built on May 29, 2017, 6:47 p.m.