Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

adjDevResidShort

Adjusted Deviance Residuals in short format


Description

Calculates the adjusted deviance residuals for arbitrary prediction models. The adjusted deviance residuals should be approximately normal distributed, in the case of a well fitting model.

Usage

adjDevResidShort(dataSet, hazards)

Arguments

dataSet

Data set in long format. Must be of class "data.frame".

hazards

Estimated hazard rates of the data in long format. Hazard rates are probabilities and therefore restricted to the interval [0, 1]

Value

  • Output: List with objects:

    • AdjDevResid: Adjusted deviance residuals as numeric vector

  • Input: A list of given argument input values (saved for reference)

Note

The argument dataSet must have a response with column name "y". The correct format of the dataset can be augmented by using dataLong.

Author(s)

References

Gerhard Tutz and Matthias Schmid, (2016), Modeling discrete time-to-event data, Springer series in statistics, Doi: 10.1007/978-3-319-28158-2

Gerhard Tutz, (2012), Regression for Categorical Data, Cambridge University Press

See Also

Examples

library(survival)

# Transform data to long format
heart[, "stop"] <- ceiling(heart[, "stop"])
set.seed(0)
Indizes <- sample(unique(heart$id), 25)
randSample <- heart[unlist(sapply(1:length(Indizes), 
function(x) which(heart$id==Indizes[x]))),]
heartLong <- dataLongTimeDep(dataSet=randSample, 
timeColumn="stop", censColumn="event", idColumn="id", timeAsFactor=FALSE)

# Fit a generalized, additive model and predict hazard rates on data in long format
library(mgcv)
gamFit <- gam(y ~ timeInt + surgery + transplant + s(age), data=heartLong, family="binomial")
hazPreds <- predict(gamFit, type="response")

# Calculate adjusted deviance residuals
devResiduals <- adjDevResidShort (dataSet=heartLong, hazards=hazPreds)$Output$AdjDevResid
devResiduals

discSurv

Discrete Time Survival Analysis

v1.4.1
GPL-3
Authors
Thomas Welchowski <welchow@imbie.meb.uni-bonn.de> and Matthias Schmid <matthias.schmid@imbie.uni-bonn.de>
Initial release
2019-12-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.