1
$\begingroup$

I'm trying to build a model based a data from package GLMsData

library(GLMsData)
data(lime)

my model is,

m <- glm(Foliage ~ DBH + Age + Origin, data = lime, 
            family = poisson (link = "log"))

here, Foliage is non integer, so it gives me inf AIC. when I use 'quasipoisson' as family, it gives AIC 'NA' and overdispersion parameter around 0.8.

  1. Can I treat this as a Poisson?
  2. If not, what would the best family link to use?
$\endgroup$
5
  • $\begingroup$ It's not an integer response and you're fitting as quasipoisson... Why would you think you could just jump to Poisson? $\endgroup$
    – Dason
    Dec 3, 2021 at 23:04
  • $\begingroup$ And why is your second question about the link instead of the family? We have no information that would provide guidance on which link would be appropriate. $\endgroup$
    – Dason
    Dec 3, 2021 at 23:05
  • $\begingroup$ Also I'm sure it's not obvious but I'm not trying to be a jerk but some research is expected on SO and your questions don't make sense to me. $\endgroup$
    – Dason
    Dec 3, 2021 at 23:05
  • $\begingroup$ hello @Dason, I'm beginnerb and sorry for my stupid question. My response variable contains some weights (in Kilograms). density plot looks like poisson, that's why I'm assuming. (i know poisson takes only positive integers) $\endgroup$
    – Tuhin Rana
    Dec 3, 2021 at 23:26
  • 1
    $\begingroup$ If descriptive plots of your data look like a Poisson but the observations are not integers then it sounds like you are dealing with a continuous distribution that might be well modeled as a gamma distribution. You could use a semi-parametric least squares model without specifying any probability distribution. Here is a related thread. $\endgroup$ Dec 4, 2021 at 1:23

2 Answers 2

4
$\begingroup$

The data (dry foliage biomass in kg) are not count data, so you shouldn't use either Poisson or quasi-Poisson responses.

The first thing to try is usually a regular linear model:

m1 <- lm(Foliage ~ DBH+Age+Origin, data = lime)
library(performance)
check_model(m1)

This is pretty terrible (if the first row [nonlinearity and heteroscedasticity] is bad, you don't even really need to look at the rest):


diagnostic plots

The next thing to try for continuous data are positive (e.g. kg of foliage) is to log-transform the response variable:

m2 <- update(m1, log(Foliage) ~ .)
check_model(m2)

This looks much better. There still seems to be slight evidence of nonlinearity and heteroscedasticity, but it's not too bad.


diagnostic plot 2


One possible solution is to see if interactions explain any of the patterns. Explore the pattern in the residuals:

library(broom)
aa <- augment(m2)
library(ggplot2)
ggplot(aa, aes(DBH,.std.resid, colour = Origin)) +
    geom_point() + 
    geom_smooth() + 
    facet_wrap(~cut_number(lime$Age, 4))

residuals vs DBH, segmented by age/origin

The fact that the downturn in the residuals occurs consistently across origins for young/small trees makes me think that it's actually a real pattern. What you would do about this would depend on how badly you needed an accurate model: for example, you could exclude the young/small trees from your model, or fit a generalized additive model, or a nonlinear model ...

As mentioned in the comments and in @GordonSmyth's answer, you could also use a Gamma GLM (probably with a log link), but the results would probably be very similar to the log-linear model ... this is

m3  <- glm(formula = Foliage ~ DBH + Age + Origin,
    family = Gamma(link = "log"), 
    data = lime)

Computing the AIC of the log-linear model (accounting for the transformation of the response variable) and the Gamma model:

AIC(m2) + sum(2*log(lime$Foliage)) - AIC(m3)
## [1] 15.43352

suggests that the Gamma model is indeed better (lower AIC is better; delta-AIC > 10 is a very large difference).

rr <- purrr::map_dfr(list(loglin = m2, Gamma = m3), augment, .id = "model")
ggplot(rr, aes(.fitted, .std.resid, colour = model)) + 
    geom_point() + geom_smooth()

However, the same nonlinear patterns are still present in the residuals (maybe a little less pronounced for the Gamma fit).

diagnostic plot

Finally, adding a squared DBH term to the model (m4 <- update(m3, . ~ . + I(DBH^2)) appears to help a lot ...

$\endgroup$
2
$\begingroup$

The GLMsData package contains the datasets used as examples in the book by Peter Dunn and myself (Dunn and Smyth, 2018).

The lime dataset is used in the book as an example of gamma regression. The main model used a log-link with Foliage as the reponse and a linear model that included a linear regression on log(DPH) for each level of Origin. The book included a careful analysis to show that the gamma mean-variance relationship is appropriate for this data.

Certainly the data would not be suitable for Poisson or quasi-Poisson regression.

Reference

Dunn PK, Smyth GK (2018). Generalized linear models with examples in R. Springer, New York, NY. https://www.amazon.com/Generalized-Linear-Examples-Springer-Statistics/dp/1441901175

$\endgroup$
3
  • 2
    $\begingroup$ do you have any thoughts about the patterns in the residuals I showed in my answer? $\endgroup$
    – Ben Bolker
    Dec 4, 2021 at 17:54
  • 1
    $\begingroup$ We used glm( Foliage ~ Origin * log(DBH), family=Gamma(link="log")) and did not see any pattern in the residuals. $\endgroup$ Dec 5, 2021 at 7:28
  • $\begingroup$ Thanks. That definitely looks better than any of the models so far -- however -- a log-linear model with the same form looks even better (in terms of residual distribution and (transformation-corrected) AIC ...) Log-log relationship between DBH and foliage also makes theoretical sense (as an allometric relationship) ... $\endgroup$
    – Ben Bolker
    Dec 5, 2021 at 19:59

Your Answer

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