martingaleResid {discSurv} | R Documentation |
Martingale Residuals
Description
Estimates the martingale residuals of discrete survival model.
Usage
martingaleResid(hazards, dataSetLong)
## S3 method for class 'discSurvMartingaleResid'
plot(x, covariates, dataSetLong, ...)
Arguments
hazards |
Predicted hazards from a discrete survival model ("numeric vector"). |
dataSetLong |
Data in long format ("class data.frame"). |
x |
Object of class "discSurvMartingaleResid"("class discSurvMartingaleResid") |
covariates |
Names of covariates to plot ("character vector"). |
... |
Additional arguments to the plot function |
Details
Gives a different plot of each marginal covariate against the martingale
residuals. Additionally a nonparametric loess
estimation is
done.
Value
Martingale residuals for each observation in long format ("numeric vector").
Author(s)
Thomas Welchowski welchow@imbie.meb.uni-bonn.de
References
Tutz G, Schmid M (2016).
Modeling discrete time-to-event data.
Springer Series in Statistics.
Therneau TM, Grambsch PM, Fleming TR (1990).
“Martingale-Based Residuals for Survival Models.”
Biometrika, 70, 147-160.
See Also
Examples
# Example with cross validation and unemployment data
library(Ecdat)
data(UnempDur)
summary(UnempDur$spell)
# Extract subset of data
set.seed(635)
IDsample <- sample(1:dim(UnempDur)[1], 100)
UnempDurSubset <- UnempDur [IDsample, ]
# Conversion to long format
UnempDurSubsetLong <- dataLong(dataShort = UnempDurSubset,
timeColumn = "spell", eventColumn = "censor1")
# Estimate discrete survival continuation ratio model
contModel <- glm(y ~ timeInt + age + logwage, data = UnempDurSubsetLong,
family = binomial(link = "logit"))
# Fit hazards to the data set in long format
hazPreds <- predict(contModel, type = "response")
# Calculate martingale residuals for the unemployment data subset
MartResid <- martingaleResid (hazards = hazPreds, dataSetLong = UnempDurSubsetLong)
MartResid
sum(MartResid)
# Plot martingale residuals vs each covariate in the event interval
# Dotted line represents the loess estimate
plot(MartResid, covariates = c("age", "logwage"), dataSetLong = UnempDurSubsetLong)