Learn R Programming

discSurv (version 1.1.2)

brierScore: Brier Score Calculation

Description

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

Usage

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 re
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).

Value

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

Details

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

See Also

adjDevResid, devResid, glm, predErrDiscShort

Examples

Run this code
# 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

Run the code above in your browser using DataLab