  Residual diagnostic methods play a critical role in assessing model
assumptions and detecting outliers in statistical modelling. In the context of
survival models with censored observations, Li et al. (2021) introduced the
Z-residual, which follows an approximately normal distribution under the true
model. This property makes it possible to use Z-residuals for diagnosing
survival models in a way similar to how Pearson residuals are used in normal
regression. However, computing residuals based on the full dataset can result
in a conservative bias that reduces the power of detecting model
mis-specification, as the same dataset is used for both model fitting and
validation. Although cross-validation is a potential solution to this problem,
it has not been commonly used in residual diagnostics due to computational
challenges. In this paper, we propose a cross-validation approach for computing
Z-residuals in the context of shared frailty models. Specifically, we develop a
general function that calculates cross-validatory Z-residuals using the output
from the \texttt{coxph} function in the \texttt{survival} package in R.Our
simulation studies demonstrate that, for goodness-of-fit tests and outlier
detection, cross-validatory Z-residuals are significantly more powerful and
more discriminative than Z-residuals without cross-validation. We also compare
the performance of Z-residuals with and without cross-validation in identifying
outliers in a real application that models the recurrence time of kidney
infection patients. Our findings suggest that cross-validatory Z-residuals can
identify outliers that are missed by Z-residuals without cross-validation.
