  In survival analysis, the hazard function often depends on a set of
covariates. Martingale and deviance residual are most widely used for examining
the validity of the function form of covariates by checking whether there is a
discernible trend in their scatterplot against continuous covariates. However,
visual inspection of martingale and deviance residuals is often subjective. In
addition, these residuals lack a reference distribution due to censoring. It is
therefore challenging to derive numerical statistical tests based on martingale
or deviance residuals. In this paper, we extend the idea of randomized survival
probability (Li et al. 2021) and develop a residual diagnostic tool that can
provide both graphical and numerical tests for checking the covariate
functional form in semi-parametric shared frailty models. We develop a general
function that calculates Z-residuals for semi-parametric shared frailty models
based on the output from the \texttt{coxph} function in the \texttt{survival}
package in R. Our extensive simulation studies indicate that the derived
numerical test based on Z-residuals has great power for checking the functional
form of covariates. In a real data application on modelling the survival time
of acute myeloid leukemia patients, the Z-residual diagnosis results show that
a model with log-transformation is inappropriate for modelling the survival
time, which could not be detected by other diagnostic methods.
