Skip to content

Extracting standardized residuals from a gamma(log) glmmTMB

5 messages · Aoibheann Gaughran, Jeff Newmiller, Mollie Brooks +1 more

#
Hi all,

I have run a glmmTMB with (family="Gamma",link="log") and now want to
validate the model, but am unable to extract the standardised residuals
with sresid <- resid(mod1tmb, "pearson").  It produces the following error
message:

Error in residuals.glmmTMB(mod1tmb, "pearson") :
variance function undefined for family ?Gamma?; cannot compute Pearson residuals


Would anyone be able to assist me with this?

Many thanks,
#
Google is your friend...

https://stats.stackexchange.com/questions/295340/what-to-do-with-glm-gamma-when-residuals-are-not-normally-distributed
#
Hi Aoibheann,

That seems to be a bug in glmmTMB since the Gamma family does include a
variance function.

I think we need to change this line of code https://github.com/
glmmTMB/glmmTMB/blob/f9388401f2173b774b16d63d31fff9
a1dbc3c48f/glmmTMB/R/methods.R#L483


Can you add an issue on GitHub (https://github.com/glmmTMB/glmmTMB/issues)?
If not, I could do it.

cheers,
Mollie
On Tue, Oct 17, 2017 at 3:54 PM, Aoibheann Gaughran <gaughra at tcd.ie> wrote:

            

  
  
#
If you specify your model with the built-in Gamma() family-generator,
this should work, e.g.:
The reason for this is that Gamma() produces a list with additional
information:

Gamma(link="log")$variance
function (mu)
mu^2

If you wanted to specify a family that base R didn't know about you
could do it by adding your own variance function to the list.
On 17-10-17 09:54 AM, Aoibheann Gaughran wrote:
#
I don't think it's a bug, except possibly a documentation bug. I.e.,
we should add details to ?glmmTMB or ?family_glmmTMB (which should
possibly be aliased to family.glmmTMB as well even though family is not
an S3 generic function, because people might look there.

 cheers
  Ben Bolker
On 17-10-17 11:33 AM, Mollie Brooks wrote: