[R-sig-ME] glmmTMB: how to get normalized residuals for use in ACF plotting

Helen Waters helen@w@ter@ @ending from gm@il@com
Fri Dec 14 11:15:02 CET 2018

Dear all,

This question is generally about glmmTMB, rather than lme4 - apologies
if this puts it out of the jurisdiction of r-sig-mixed-models.

I've been using glmmTMB to implement beta GLMMs. The data I'm using
was collected from a series of plots that were measured continually,
every three months, for ~2 years.

I would like to use ACF plots to look at possible temporal
auto-correlation in the residuals, and in the event that I need to
include a correlation structure (e.g. AR1), I would like to see how
well any such structure accounts for the auto-correlation.

I read here: https://stats.stackexchange.com/questions/80823/do-autocorrelated-residual-patterns-remain-even-in-models-with-appropriate-corre

...and here: http://bbolker.github.io/mixedmodels-misc/ecostats_chap.html

...that it is necessary to use the normalized residuals for ACF
plotting, rather than the raw residuals, as the raw residuals contain
no information on any correlation terms. The information in the
residuals.glm help file also implies that pearson/standardized
residuals may be no good for this?:

"type: an optional character string specifying the type of residuals
      to be used. If ‘"response"’, the "raw" residuals (observed -
      fitted) are used; else, if ‘"pearson"’, the standardized
      residuals (raw residuals divided by the corresponding
      standard errors) are used; else, if ‘"normalized"’, the
      normalized residuals (standardized residuals pre-multiplied
      by the inverse square-root factor of the estimated error
      correlation matrix) are used. Partial matching of arguments
      is used, so only the first character needs to be provided.
      Defaults to ‘"response"’."

Assuming it is indeed the normalized residuals that I need, does
anyone know how I could derive them from a glmmTMB object? The
residuals.glmmTMB function currently only accepts "response" and
"pearson" as 'type' arguments.

If it is necessary to calculate them 'by hand', then what R code
should I use to convert the standardized residuals, as per the
definition above? (i.e. "standardized residuals pre-multiplied by the
inverse square-root factor of the estimated error correlation

Apologies if I have misunderstood any concepts here, I am new to
analysing time series data.

Many thanks in advance,

More information about the R-sig-mixed-models mailing list