adjDevResid: Adjusted Deviance Residuals

adjDevResidR Documentation

Adjusted Deviance Residuals

Description

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

Usage

adjDevResid(dataLong, hazards)

## S3 method for class 'discSurvAdjDevResid'
plot(x, ...)

Arguments

dataLong

Data set in long format (class "data.frame").

hazards

Estimated discrete hazards of the data in long format (class "numeric"). Hazard rates are probabilities and therefore restricted to the interval [0, 1].

x

Object of class "discSurvAdjDevResid"

Details

Is called implicitly by using function qqnorm on an object of class "discSurvAdjDevResid". It plots a qqplot against the normal distribution. If the model fits the data well, it should be approximately normal distributed.

Value

  • Output List with objects:

    • AdjDevResid Adjusted deviance residuals as class "numeric"

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

Author(s)

Thomas Welchowski t.welchowski@psychologie.uzh.ch

References

\insertRef

tutzRegCatdiscSurv

\insertReftutzModelDiscdiscSurv

See Also

intPredErr, predErrCurve

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(dataSemiLong = randSample, 
timeColumn = "stop", eventColumn = "event", idColumn = "id", timeAsFactor = FALSE)

# Fit a generalized, additive model and predict discrete hazards 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 <- adjDevResid(dataLong = heartLong, hazards = hazPreds)$Output$AdjDevResid
devResiduals


discSurv documentation built on April 29, 2026, 9:07 a.m.