[R-sig-ME] glmmTMB warnings and no output Gamma distribution
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Wed Feb 5 19:33:29 CET 2020
For what it's worth, the use of the inverse link as the default for
the Gamma is because it's the *canonical* link for that distribution -
this can be derived from the form of the distribution function, and
has some nice mathematical properties (see Wikipedia
https://en.wikipedia.org/wiki/Generalized_linear_model or any GLM
book). It is indeed often less numerically stable than the log link,
which restricts the domain appropriately.
On Wed, Feb 5, 2020 at 11:01 AM Mollie Brooks <mollieebrooks using gmail.com> wrote:
>
> Hi Willem,
>
>
> > On 3Feb 2020, at 10:03, Willem (Wim) Kaijser <willem.kaijser using uni-due.de> wrote:
> >
> > Hello, It was suggested to me to place my question in this mailing-list. I have some problems and lack of knowledge constructing a GLMM with the glmmTMB package (version 0.2.03). Therefore, I am sorry If the explanation is not as sufficient as it should be, and want to thank you in advance for your time.
> >
> > I try to include both fixed plus random effects and correction for serial correlation in a GLMM with a Gamma distribution (link = "inverse"). However, I get several warnings and the processing time is long, so I prematurely stopped the permutations (see the code below). If the Gamma distribution, with “log” link, is used in the model containing only the fixed and random effects; these warnings do not occur. Including this with the model correcting for serial correlation it does return a warning, but I can extract the residuals (AIC and BIC are returned as NA though). This seems like the following issue: https://github.com/glmmTMB/glmmTMB/issues/329. However, this seems to be resolved. What might be the issue here (is it my coding)?
> >
> > ############################################################
> > #Code with only the fixed and random effects with warnings:#
> > ############################################################
> >
> > mod1 <- glmTMB(Chla ~ pCO2 + (1|River/ID), family = ”Gamma”, data = df)
> >
> > There were 19 warnings (use warnings() to see them)
> > Timing stopped at: 33.7 0.08 34.19
> >
> > Warning messages:
> > 1: In nlminb(start = par, objective = fn, gradient = gr, ... :
> > NA/NaN function evaluation
> >
> This coding looks correct, but can you say something about River and ID in the design. Are the labels for the levels of one reused in the levels of the other?
>
> The default in glmmTMB is to use an inverse link with the Gamma family because that’s what glm() does in base R, but I don’t actually know why. Since the mean has to be positive, I would guess that a log link is a good thing to try, but maybe someone else can explain why inverse is the default.
>
> > #######################################################################################
> > #Code with both the fixed, random and correction for serial correlation with warnings:#
> > #######################################################################################
> >
> > mod2 <- glmTMB(Chla ~ pCO2 + (1|River/ID) + ar1(1|Month), family = ”Gamma”, data = df)
>
> This coding is not correct. Check out the issue you linked to. https://github.com/glmmTMB/glmmTMB/issues/329 <https://github.com/glmmTMB/glmmTMB/issues/329>
>
> If Month is an integer, then you could use ar1(Month+0 | X) where X is probably ID, or possibly River depending on the design. This also depends on if the experiment ran for more than 12 months, in which case, you do not want to repeat 1:12 in the second year if it is based on calendar months. In ar1(Time +0 | X), you need Time to continue counting even if Month repeats according to the calendar in the data.
>
> Cheers,
> Mollie
>
> >
> > There were 20 warnings (use warnings() to see them)
> > Timing stopped at: 24.71 0.08 25.49
> >
> > Warning messages:
> > 1: In FUN(X[[i]], ...) : AR1 not meaningful with intercept
> > 2: In nlminb(start = par, objective = fn, gradient = gr, ... :
> > NA/NaN function evaluation
> >
> > Best regards,
> > --
> > Willem (Wim) Kaijser
> >
> > Fakultät für Biologie
> > Aquatische Ökologie
> > Universitätsstr. 5
> > D-45141 Essen
> >
> > Room: S05T03B02
> > Tel: +49.201.183.3113
> >
> > _______________________________________________
> > R-sig-mixed-models using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
More information about the R-sig-mixed-models
mailing list