0
$\begingroup$

I'm trying to run some models on bee presence with five predictor variables. A snippet of the data is attached, but essentially I measured floral abundance and richness, calculated floral evenness and diversity, measured canopy cover (%), and the dependent variable is the guild/functional group diversity (last column). Elevation band is a factor with 5 levels.

Snippet of dataset. Column labels are: ElevationBand, FloralAbund, FloralRich, FloralEven, FloralDiv, Canopy, GuildDiv

I have tested for normality; the response data is not normally distributed even if log transformed.

I tried fitting to Poisson and negative binomial, but it appears that beta fits best. I used descdist(fxndat$GuildDiv, boot=10000) to get the Cullen and Frey graph (attached).

Cullen and Frey graph showing beta distribution

I'm pretty comfortable with the glm() function with normally distributed data, but I'm having trouble finding documentation on how to approach modeling with the beta distribution as that's not an option for the "family" argument (or at least, it's not listed in the glm function documentation).

Is there a different function I should use? Additionally, my diversity indices don't necessarily fit within the (0,1) parameter that I've read for the beta distribution, so I'm not sure I should even use a GLM.

$\endgroup$
3
  • 2
    $\begingroup$ You may want to take a look at betareg function from betareg package. $\endgroup$ Commented Jun 26 at 20:45
  • 2
    $\begingroup$ Just want to check that when you say "the response data is not normally distributed even if log transformed" that you are testing the residuals of a model, not the data itself. Response data is practically never normally distributed. This is not a problem. $\endgroup$ Commented Jun 26 at 20:48
  • $\begingroup$ PS please include your data snippet in text form (e.g., cut-and-pasted text in a code block) rather than as an image/screenshot. Is it possible for you to provide a link to the whole data set? $\endgroup$
    – Ben Bolker
    Commented Jun 26 at 22:27

1 Answer 1

0
$\begingroup$

The Beta regression family is not a generalised linear model (in any of the strict senses) and so glm can't give you the maximum likelihood estimators (not with the pre-defined family options and not with user-defined ones either).

You can get a reasonable approximation to the Beta model from a glm with family=quasi(link="logit", variance="mu(1-mu)"), since the variance of a Beta with mean $\mu=\alpha/(\alpha+\beta)$ is $$\frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}=\mu(1-\mu)\phi$$ with $\phi=1/(\alpha+\beta+1)$ being a dispersion parameter. This is obviously only useful for estimating trends, not for prediction intervals, since there's no parametric model.

In fact, even modelling $\mathrm{logit}\,Y$ with linear regression and a sandwich variance estimator works pretty well if you are interested in trends (you need the sandwich estimator because the variance of $\mathrm{logit}\, Y$ increases as $Y$ moves away from 1/2).

But there is in fact software for maximum likelihood fitting (eg betareg), so you might as well use that instead of forcing it into glm.

All these assume the outcome is within some prespecified interval: by default $[0,1]$ but you can transform the data if the interval is something else. That's pretty fundamental to these models because the main challenge they are dealing with is the hard limits at both ends of the interval.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.