[R-sig-ME] Extracting standardized residuals from a gamma(log) glmmTMB

Ben Bolker bbolker at gmail.com
Tue Oct 17 17:36:36 CEST 2017


  If you specify your model with the built-in Gamma() family-generator,
this should work, e.g.:

> library(glmmTMB)
> dd <- data.frame(g=rgamma(100,shape=4,scale=1))
> g1 <- glmmTMB(g~1,family=Gamma(link="log"),data=dd)
> resid(g1,"pearson")

  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:
> 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,
>



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