spaMM (version 2.1.6)

plot.HLfit: Model checking plots for mixed models

Description

This function provides diagnostic plots for residual errors from the mean model and for random effects. Plots for the mean models are similar to those for GLMs, as described in Lee et al. 2006. Plots for residual errors consider the standardized deviance residuals (Lee et al. 2006, p.52), and plots for random effects likewise consider standardized values, i.e. each random deviate divided by \(\sqrt(1-q)\) where \(q\) is the corresponding leverage for \(\lambda\).

Usage

# S3 method for HLfit
plot(x, which = c("mean", "ranef"), 
      titles = list(
          meanmodel=list(outer="Mean model",devres="Deviance residuals", 
                         absdevres="|Deviance residuals|", resq="Residual quantiles", 
                         devreshist="Deviance residuals"), 
          ranef=list(outer="Random effects and leverages",qq="Random effects Q-Q plot", 
                     levphi=expression(paste("Leverages for ",phi)), 
          levlambda=expression(paste("Leverages for ",lambda))) 
        ), 
      control= list(), ...)

Arguments

x

The return object of an HLCor / HLfit / corrHLfit call.

which

A vector of keywords for different types of plots. By default, two types of plots are presented on different devices: diagnostic plots for mean values, and diagnostic plots for random effects. Either one can be selected using this argument. Use keyword "predict" for a plot of predicted response against actual response.

titles

A list of the main (inner and outer) titles of the plots. See the default value for the format.

control

A list of default options for the plots. Defaults are pch="+" and pcol="blue" for points, and lcol="red" for curves.

Options passed from plot.HLfit to par.

Value

Returns the input object invisibly.

Details

The standardized deviance residuals are defined as the deviance residuals divided by \(\phi\sqrt(1-q)\), where \(q\) is the corresponding leverage for \(\phi\), and the deviance residuals are defined as for a GLM. The leverages are zero for ML methods. Otherwise, they depend on the fitting method used, as defined in the Details of HLfit. The PQL and EQL- method use leverages obtained as diagonal elements of the “hat” matrix; more elaborate methods will introduce corrections for non-Gaussian response and for non-Gaussian random effects; and “(.,1)” methods will add another correction taking into account the variation of the GLM weights in the logdet Hessian term of restricted likelihood.

In principle the deviance residuals for the mean model should have a nearly Gaussian distribution hence form a nearly straight line on a Q-Q plot. However this is (trivially) not so for well-specified (nearly-)binary response data nor even for well-specified Poisson response data with moderate expectations. Hence this plot is not so useful.

References

Lee, Y., Nelder, J. A. and Pawitan, Y. (2006). Generalized linear models with random effects: unified analysis via h-likelihood. Chapman & Hall: London.

Examples

Run this code
# NOT RUN {
## see example for data(scotlip)
# }

Run the code above in your browser using DataCamp Workspace