I am fitting a linear model for de CO2 dataset in R, I want to predict plant uptake (always positive) using Type, conc, and treatment, a quick look at the data gives me this relationship:

enter image description here

which is a saturation curve, it is clear that there is an effect by plant type, and that there is an interaction with treatment, also this are repeated measures from plants at different concentrations, so I thought random effects from plants make sense.

So I set up my linear models with and without random effects:


mod1 <- lm(uptake ~ Type*Treatment + 
          I(log(conc)) + conc, data = CO2)

mod2 <- lmer(uptake ~ Type*Treatment + 
           I(log(conc)) + conc + (1|Plant), 
              data = CO2)

Now when I see the residuals of mod1

enter image description here

and mod2

enter image description here

I am not at all happy with the structure of the residuals, they seem to be heteroscedastic. which made me think I should go to glm or glmm, I am very familiar with the Poisson glm and binomial glm, but in this case, since it is a continuous positive I thought gamma family should be better. But when I read about it and see that the identity is inverse, I thought that it didn't make any sense to me to model the inverse of CO2 uptake.

I fitted these models anyway

mod3 <- glm(uptake ~ Type*Treatment + 
  I(log(conc)) + conc, data = CO2, family = 

mod4 <- glmer(uptake ~ Type*Treatment + 
  I(log(conc)) + conc + (1|Plant), data = 
    CO2, family = Gamma)

mod4 failed altogether, and even when mod3 improved the residuals

enter image description here

I am not sure that I am using the family for the right reason.

  • $\begingroup$ How did you obtain the last plot? Have you tried other transformations other than log, for ex. polynomials, splines? Your residuals appear to have a U shape (maybe). $\endgroup$ Oct 11, 2018 at 11:07
  • $\begingroup$ For the last plot I used broom::augment(mod3) and then used ggplot to plot .fitted against . resid, I didn't try other transformations, since I used the log mostly to capture the saturation of CO2 Uptake, but I will try. Thanks $\endgroup$ Oct 11, 2018 at 17:00
  • $\begingroup$ ... But when I read about it and see that the identity is inverse you mean the default link function is inverse, but you could still choose some other link function! $\endgroup$ Aug 31, 2021 at 13:54

1 Answer 1


The non-linear form of the residuals suggests that you may need to include non-linear effects in your model (e.g., quadratic effect, etc).

I don't necessarily think you need the gamma distribution; try other additions to your original model or you could model the data that are less than 230 (or wherever the point where you have that clumping) separately.

  • $\begingroup$ +1 indeed the curves don't look linear at all. However, instead of using quadratic effects it might be possibly better to use some realistic model based on first principles. It looks like these curves are some exponential function of concentration and that might have a physical explanation. In addition it seems like there are some random effects included. For the same class of points (treatment * type) we see subsets of points that follow, very closely, different curves. This might indicate that these points are from seperate experiments where parameters where slightly different. $\endgroup$ Jun 4 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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