There's more...

After a model has been fitted, it is important to analyze the residuals. We need to take some extra care because the data will belong to groups. Thus, we need to do a separate analysis for each group:

plot(model, resid(., scaled=TRUE) ~ fitted(.) | clientid, abline = 0) 

The following output shows the fitted versus the residuals. These look good, and there is no obvious traces of structure here:

Then, type the following code:

plot(model, clientid ~ resid(., scaled=TRUE)) 

The following output shows the scaled residuals for each group:

In the previous two plots, we first showed the fitted-residual relationship; ideally, there ...

Get R Statistics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.