Discussion:
[R-sig-ME] Fitting GLMM to percent cover data with glmmTMB
Vasco Silva
2018-11-29 21:24:42 UTC
Permalink
Hi,
str(cover)
'data.frame': 100 obs. of 114 variables:
$ Plot : Factor w/ 10 levels "P1","P10","P2",..: 1 1 1 1 1 3 3 ...
$ Sub.plot: Factor w/ 5 levels "S1","S2","S3",..: 1 2 3 4 5 1 2 ...
$ Grazing : Factor w/ 2 levels "Fenced","Unfenced": 1 1 1 1 1 1 1 ...
$ sp1 : int 0 0 0 1 0 0 1 ...
$ sp2 : int 0 0 0 0 0 3 3 ...
$ sp3 : int 0 1 0 0 1 3 3 ...
$ sp4 : int 1 3 13 3 3 3 0 ...
$ sp6 : int 0 0 0 0 0 0 0 ...
...
$ tot : int 93 65 120 80 138 113 ...

I was wondering whether the GLMM can be fitted with glmmTMB (tweedie
distribution) and if so, should I use percent cover or percent cover
converted to relative abundance?

sp1.glmm <- glmmTMB (sp1 ~ Grazing + (1|Plot), data=cover, family=tweedie
(link ="logit"))

Any advice would be very much appreciated.

Cheers.

Vasco Silva

[[alternative HTML version deleted]]
Vasco Silva
2018-11-30 09:27:37 UTC
Permalink
Apologies for eventual cross-posting.

Vasco
Post by Vasco Silva
Hi,
str(cover)
$ Plot : Factor w/ 10 levels "P1","P10","P2",..: 1 1 1 1 1 3 3 ...
$ Sub.plot: Factor w/ 5 levels "S1","S2","S3",..: 1 2 3 4 5 1 2 ...
$ Grazing : Factor w/ 2 levels "Fenced","Unfenced": 1 1 1 1 1 1 1 ...
$ sp1 : int 0 0 0 1 0 0 1 ...
$ sp2 : int 0 0 0 0 0 3 3 ...
$ sp3 : int 0 1 0 0 1 3 3 ...
$ sp4 : int 1 3 13 3 3 3 0 ...
$ sp6 : int 0 0 0 0 0 0 0 ...
...
$ tot : int 93 65 120 80 138 113 ...
I was wondering whether the GLMM can be fitted with glmmTMB (tweedie
distribution) and if so, should I use percent cover or percent cover
converted to relative abundance?
sp1.glmm <- glmmTMB (sp1 ~ Grazing + (1|Plot), data=cover, family=tweedie
(link ="logit"))
Any advice would be very much appreciated.
Cheers.
Vasco Silva
[[alternative HTML version deleted]]
Mollie Brooks
2018-11-30 11:21:04 UTC
Permalink
Hi Vasco,
I agree with Zoltan that bionimial is probably inappropriate, for the reasons he stated.
I'm not sure that Tweedie is your solution though -- it is defined for non-negative real numbers.
Not just those between 0 and 100%. Perhaps easiest to think of fish biomass caught in a net (can
be zero, or more.
Tweedie might work though, if your percentages are typically nowhere near the 100% boundary. In
this case, the upper end of the support is kind of immaterial... You hope...
Does glmmTMB supply a beta distribution? Zero-inflated beta? The quantile regression idea might be
useful too, as Brian suggested, but I'm not sure about random effects in that case. Beta regression
will also have problems with exactly 0% (or 100%) observations.
I would convert percentages to the 0-1 scale and then try a zero-inflated beta distribution. The Tweedie makes more sense if your response variable is the sum of a bunch of positive values like body weights.

You can do a GLMM with a zero-inflated beta distribution in glmmTMB with something like

m1 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~1, data=cover, family=beta_family())
m2 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~ Grazing, data=cover, family=beta_family())

cheers,
Mollie
Hi,
str(cover)
$ Plot : Factor w/ 10 levels "P1","P10","P2",..: 1 1 1 1 1 3 3 ...
$ Sub.plot: Factor w/ 5 levels "S1","S2","S3",..: 1 2 3 4 5 1 2 ...
$ Grazing : Factor w/ 2 levels "Fenced","Unfenced": 1 1 1 1 1 1 1 ...
$ sp1 : int 0 0 0 1 0 0 1 ...
$ sp2 : int 0 0 0 0 0 3 3 ...
$ sp3 : int 0 1 0 0 1 3 3 ...
$ sp4 : int 1 3 13 3 3 3 0 ...
$ sp6 : int 0 0 0 0 0 0 0 ...
...
$ tot : int 93 65 120 80 138 113 ...
I was wondering whether the GLMM can be fitted with glmmTMB (tweedie
distribution) and if so, should I use percent cover or percent cover
converted to relative abundance?
sp1.glmm <- glmmTMB (sp1 ~ Grazing + (1|Plot), data=cover, family=tweedie
(link ="logit"))
Any advice would be very much appreciated.
Cheers.
Vasco Silva
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Vasco Silva
2018-11-30 20:21:30 UTC
Permalink
Thanks Mollie.

I convert % cover to relative abundance using "decostand" function and fit
sp1.glm1<-glmmTMB(sp1~Grazing+(1|Plot),zi=~0, data=cover,
+ family=beta_family(link ="logit"))
Error in eval(expr, envir, enclos) : y values must be 0 < y < 1

Cheers.

Vasco
Hi Vasco,
I agree with Zoltan that bionimial is probably inappropriate, for the
reasons he stated.
I'm not sure that Tweedie is your solution though -- it is defined for
non-negative real numbers.
Not just those between 0 and 100%. Perhaps easiest to think of fish
biomass caught in a net (can
be zero, or more.
Tweedie might work though, if your percentages are typically nowhere
near the 100% boundary. In
this case, the upper end of the support is kind of immaterial... You
hope...
Does glmmTMB supply a beta distribution? Zero-inflated beta? The
quantile regression idea might be
useful too, as Brian suggested, but I'm not sure about random effects in
that case. Beta regression
will also have problems with exactly 0% (or 100%) observations.
I would convert percentages to the 0-1 scale and then try a zero-inflated
beta distribution. The Tweedie makes more sense if your response variable
is the sum of a bunch of positive values like body weights.
You can do a GLMM with a zero-inflated beta distribution in glmmTMB with something like
m1 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~1, data=cover,
family=beta_family())
m2 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~ Grazing, data=cover, family=beta_family())
cheers,
Mollie
Hi,
str(cover)
$ Plot : Factor w/ 10 levels "P1","P10","P2",..: 1 1 1 1 1 3 3 ...
$ Sub.plot: Factor w/ 5 levels "S1","S2","S3",..: 1 2 3 4 5 1 2 ...
$ Grazing : Factor w/ 2 levels "Fenced","Unfenced": 1 1 1 1 1 1 1 ...
$ sp1 : int 0 0 0 1 0 0 1 ...
$ sp2 : int 0 0 0 0 0 3 3 ...
$ sp3 : int 0 1 0 0 1 3 3 ...
$ sp4 : int 1 3 13 3 3 3 0 ...
$ sp6 : int 0 0 0 0 0 0 0 ...
...
$ tot : int 93 65 120 80 138 113 ...
I was wondering whether the GLMM can be fitted with glmmTMB (tweedie
distribution) and if so, should I use percent cover or percent cover
converted to relative abundance?
sp1.glmm <- glmmTMB (sp1 ~ Grazing + (1|Plot), data=cover, family=tweedie
(link ="logit"))
Any advice would be very much appreciated.
Cheers.
Vasco Silva
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
[[alternative HTML version deleted]]
Mollie Brooks
2018-12-02 14:19:19 UTC
Permalink
Sorry, I had been thinking that the ziformula in glmmTMB would handle the zeros, but I just realized that, for now, the zeros have to be fit with a separate model because of a call to family$initialize which checks the response variable. https://github.com/glmmTMB/glmmTMB/issues/355 <https://github.com/glmmTMB/glmmTMB/issues/355>

So for now, you could either fit the hurdle in two separate models in glmmTMB or fit a single model in gamlss.

cheers,
Mollie
Post by Vasco Silva
Thanks Mollie.
sp1.glm1<-glmmTMB(sp1~Grazing+(1|Plot),zi=~0, data=cover,
+ family=beta_family(link ="logit"))
Error in eval(expr, envir, enclos) : y values must be 0 < y < 1
Cheers.
Vasco
Hi Vasco,
I agree with Zoltan that bionimial is probably inappropriate, for the reasons he stated.
I'm not sure that Tweedie is your solution though -- it is defined for non-negative real numbers.
Not just those between 0 and 100%. Perhaps easiest to think of fish biomass caught in a net (can
be zero, or more.
Tweedie might work though, if your percentages are typically nowhere near the 100% boundary. In
this case, the upper end of the support is kind of immaterial... You hope...
Does glmmTMB supply a beta distribution? Zero-inflated beta? The quantile regression idea might be
useful too, as Brian suggested, but I'm not sure about random effects in that case. Beta regression
will also have problems with exactly 0% (or 100%) observations.
I would convert percentages to the 0-1 scale and then try a zero-inflated beta distribution. The Tweedie makes more sense if your response variable is the sum of a bunch of positive values like body weights.
You can do a GLMM with a zero-inflated beta distribution in glmmTMB with something like
m1 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~1, data=cover, family=beta_family())
m2 <- glmmTMB(sp1 ~ Grazing + (1|Plot), zi=~ Grazing, data=cover, family=beta_family())
cheers,
Mollie
Hi,
str(cover)
$ Plot : Factor w/ 10 levels "P1","P10","P2",..: 1 1 1 1 1 3 3 ...
$ Sub.plot: Factor w/ 5 levels "S1","S2","S3",..: 1 2 3 4 5 1 2 ...
$ Grazing : Factor w/ 2 levels "Fenced","Unfenced": 1 1 1 1 1 1 1 ...
$ sp1 : int 0 0 0 1 0 0 1 ...
$ sp2 : int 0 0 0 0 0 3 3 ...
$ sp3 : int 0 1 0 0 1 3 3 ...
$ sp4 : int 1 3 13 3 3 3 0 ...
$ sp6 : int 0 0 0 0 0 0 0 ...
...
$ tot : int 93 65 120 80 138 113 ...
I was wondering whether the GLMM can be fitted with glmmTMB (tweedie
distribution) and if so, should I use percent cover or percent cover
converted to relative abundance?
sp1.glmm <- glmmTMB (sp1 ~ Grazing + (1|Plot), data=cover, family=tweedie
(link ="logit"))
Any advice would be very much appreciated.
Cheers.
Vasco Silva
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models <https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>
[[alternative HTML version deleted]]

Loading...