Solution (source code)

= Solution

A <martingale residual> is observed minus model-expected event count:
$$
\widehat M_i=v_i-\widehat\Lambda_i(x_i),
$$
where $\widehat\Lambda_i$ is the fitted individual <cumulative hazard>. Under an adequate model it estimates the terminal value of a counting-process <martingale>.

Fit a model omitting the continuous explanatory variable $z$, plot $\widehat M_i$ against $z_i$, and add a flexible smooth curve. A curve fluctuating around zero without structure supports omission. A monotone or curved trend indicates that event incidence still depends on $z$, suggesting inclusion of $z$ or a nonlinear transformation of it. The residuals are highly skewed, so the smoothed trend is more informative than an assumption of Gaussian scatter.