How to use nlmer from lme4 with non-Normal data

503 Views Asked by At

I am testing some non-linear models with nlmer from the lme4 library. But this function assumes normality while my data clearly follows a Gamma distribution.

fit <- lme4::nlmer(y ~ nfun(x, b0, b1, b2) ~
                 (b0|id),
             data = df,
             start = start.df, REML=T)
summary(fit)

Is there a way of adding a family group, as for lme4, or any other tips for testing groups within non-linear models when data is not Gaussian?

1

There are 1 best solutions below

0
Ben Bolker On

The options for fitting non-linear generalized mixed models in (pure) R are slim to nonexistent.

  • the brms package offers some scope for nonlinear fitting
  • you can build a nonlinear model in TMB (but you have to do your own programming in an extension of C++)
  • other front-end packages like rethinking, greta, rjags, etc. also allow you to build nonlinear mixed effects models — but all (?) in a Bayesian/MCMC framework

On the other hand, Gamma-based models can often be adequately substituted by log-Normal-based models (i.e. log(y) ~ nfun(x, b0, b1, b2)); while the tail shapes of these distributions are very different, the variance-mean relationship for the standard parameterizations is the same, and the results of a (log-link) Gamma GLMM and the corresponding log-Gaussian model are often very similar.

Or you could use a fixed effect for the groups (if you have enough data) and use bbmle::mle2 with the params argument.