# Intuition behind martingale residuals and their properties in survival modeling

I am reading Tutz & Schmid "Modeling Discrete Time-to-Event Data" (2016) chapter 4 Evaluation and Model Choice section 4.2 Residuals and Goodness-of-Fit. A martingale residual is defined as $$m_i = \delta_i - \sum_{s=1}^{t_i} \hat\lambda_{is}, \quad i=1,\dots,n.$$ Here, $$\delta_i$$ is a binary 0-1 indicator of whether individual $$i$$ experienced an event over the time periods 1 to $$t_i$$. (If not, the individual has survived beyond $$t_i$$ without experiencing the event.) $$\hat\lambda_{is}$$ is the estimated hazard, i.e. the conditional probability that individual $$i$$ will experience the event in the time period $$s$$ given the individual has survival until the beginning of that period without having experienced the event (and potentially given some covariates).

I do not get the intuition of summing up the hazards over time. We could sum up the estimated unconditional probabilities $$\hat\pi_{is}$$ to obtain the estimated probability of experiencing the event in at least one of the time periods between 1 and $$t_i$$, that would seem intuitive to me. And we could intuitively compare that to $$\delta_i$$; a good model would yield a small difference $$m_i$$, and a bad model would yield a large difference. But what kind of intuition can there be behind summing the hazards and comparing them to $$\delta_i$$?

Moreover, it is said that for the logistic model, the martingale residuals sum up to zero. That does not sound intuitive to me either. That would be more or less intuitive if we had $$\sum_{s=1}^{t_i} \hat\pi_{is}$$ instead of $$\sum_{s=1}^{t_i} \hat\lambda_{is}$$. However, I would expect $$\sum_{s=1}^{t_i} \hat\lambda_{is} > \sum_{s=1}^{t_i} \hat\pi_{is}$$ and thus $$m_i$$ to be negative on average and in sum.

What am I missing? I think what you're missing is what happens when martingale residuals are summed over all individuals. That's combined with the somewhat less-than-intuitive interpretation of the cumulative hazard:

$$\Lambda(t_i) =\sum_{s=1}^{t_i} \hat\lambda_{is}, \quad i=1,\dots,n$$

and some Tutz-Schmid ambiguity in whether $$i$$ is an index for individuals or for time points. Let's remove that ambiguity by rewriting the above, with $$k$$ the index of discrete times and $$i$$ for the $$n$$ individuals:

$$\Lambda_i(t_k) =\sum_{s=1}^{t_k} \hat\lambda_{is}, \quad i=1,\dots,n$$

This form emphasizes that hazards at discrete times and the cumulative hazard can differ among individuals, as functions of covariates, individual frailties, etc.

For intuition on this and other aspects of survival analysis, I'd recommend Therneau and Grambsch over Tutz and Schmid. As Therneau and Grambsch quote (from an unspecified source) on page 13:

In words, "the total estimated hazard, summed over subjects equals the total number of observed events."

That is:

$$\sum_{i=1}^n \left[\delta_i(\infty) -\Lambda_i(\infty)\right] = 0 ,$$

a restatement of Equation 2.7 from Therneau and Grambsch into the terminology from Tutz and Schmid (as adapted here). That allows both for individuals with right-censored event times $$(\delta_i(\infty)=0)$$ and for individuals with repeated events $$(\delta_i(\infty)>1)$$.

In Section 2.2, Therneau and Grambsch provide an accessible account of the connection between the counting-process analysis of survival data and martingale theory. It's the patterns of deviations in martingale residuals, as they continue to their ultimate sum to 0 over time, that help inform things like how to describe the functional forms of covariate associations with outcome.

Chapters 4 and 5 of Therneau and Grambsch go into further detail on their use. Table 20.3 of Harrell's RMS text summarizes ways to use them, with examples in Chapter 20.