Compute residuals for a glmmTMB object
Details
Residuals are computed based on predictions of type "response", i.e. equal to the conditional mean for non-zero-inflated models and to
mu*(1-p)for zero-inflated modelsComputing deviance residuals depends on the implementation of the
dev.residsfunction from the object'sfamilycomponent; at present this returnsNAfor most "exotic" families (i.e. deviance residuals are currently only implemented for families built into base R plusnbinom1,nbinom2). Deviance residuals are based on the conditional distributions only, i.e. ignoring zero-inflation components.Deviance is computed as the sum of squared deviance residuals, so is available only for the families listed in the bullet point above. See deviance.merMod for more details on the definition of the deviance for GLMMs.
for distributions in the exponential dispersion family (Gaussian, Poisson, binomial, Gamma), for models with a fixed dispersion parameter (Poisson, binomial) or constant
dispformulacomponent, reported Pearson residuals are only scaled by a factor proportional to the residual standard deviation (for compatibility with base R); divide these values bysigma(fitted_model)to get raw residuals scaled by the standard deviation. For all other distributions/models, Pearson residuals are scaled by the residual standard deviation. (The beta-binomial currently returns unscaled residuals.)