Residual diagnostics is an important topic in the classroom, but it is less often used in practice when the response is binary or ordinal. Part of the reason for this is that generalized models for discrete data, like cumulative link models and logistic regression, do not produce standard residuals that are easily interpreted as those in ordinary linear regression. In this paper, we introduce the R package sure, which implements a recently developed idea of SUrrogate REsiduals. We demonstrate the utility of the package in detection of cumulative link model misspecification with respect to mean structures, link functions, heteroscedasticity, proportionality, and interaction effects.
BootstrappingSince the surrogate residuals are based on random sampling, additional variability is introduced. One way to account for this sample variability and help stabilize any patterns in diagnostic plots is to use the bootstrap (Efron, 1979).The procedure for bootstrapping surrogate residuals is similar to the model-based bootstrap algorithm used in linear regression. To obtain the b-th bootstrap replicate of the residuals, Liu and Zhang (2017) suggest the following algorithm:Step 1 Perform a standard case-wise bootstrap of the original data to obtain the bootstrap sample X 1b , Y 1b , . . . , X nk , Y nk .Step 2 Using the procedure outlined in the previous section, obtain a sample of surrogate residuals R S 1b , . . . , R S nb using the bootstrap sample obtained in Step 1.This procedure is repeated a total of B times. For residual-vs-covariate (i.e., R-vs-x) plots and residual-vs-fitted value (i.e., R-vs-f X, β ) plots, we simply scatter all B × n residuals on the same plot. This approach is valid since the bootstrap samples are drawn independently. For large data sets, we find it useful to lower the opacity of the data points to help alleviate any issues with overplotting. For Q-Q plots, on the other hand, Liu and Zhang (2017) suggest using the median of the B bootstrap distributions, which is the implementation used in the sure package (Greenwell et al., 2017).
Surrogate residuals in RThe sure package supports a variety of R packages for fitting cumulative link and other types of models. The supported packages and their corresponding functions are described in Table 2.The sure package currently exports four functions:• resids-for constructing surrogate residuals;