# Not sure if a gamma glm or glmm is needed

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:

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:

data(CO2)
library(lme4)

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

and mod2

I am not at all happy with the structure of the residuals, they seem to have 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 though 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 = Gamma)

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

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

any orientation would be welcome

• 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). – user2974951 Oct 11 '18 at 11:07
• 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 – Derek Corcoran Oct 11 '18 at 17:00