[R-sig-eco] Fixing heteroscedasticity in mixed-effects model?

Ben Bolker bbolker at gmail.com
Thu Mar 29 21:41:42 CEST 2012


Malin Pinsky <malin.pinsky at ...> writes:

> I'm having problems fitting a mixed-effects model for an ecological
> meta-analysis, and I'm curious if anyone has advice. In particular,
> it's pretty clear that the variance in the residuals increases with
> the predicted mean, but my normal fixes don't seem to be working. The
> model is:
> 
> mod1 <- lmer(logCd ~ logRe + Hab + logRe:Hab + (logRe|Study), data=temp)
> 
> where Cd is a drag coefficient (>0 before log-transformation), Re is a
> physical quantity called a Reynolds number (also >0 before
> transformation), Hab is a categorical variable for habitat, and Study
> is a categorical variable for the study the data came from. I know
> from fluid dynamics theory that logCd and logRe can be linearly
> related, but I expect that the slope and intercept vary between
> habitat types and between studies.

  [big snip to make gmane happy]

> And, if this belongs on the R-sig-ME list, let me know.

  Probably.

  A quick answer is that you should able to incorporate heteroscedasticity
in lme (from the nlme function) via something like weights=varPower():

mod1 <- lme(logCd ~ logRe*Hab, random=~logRe|Study, data=temp,
   weights=varPower())

(this might not be quite right, you might want to read ?nlme::varPower
and/or the relevant bit of Pinheiro and Bates 2000)

  If you want to go the Gamma route, you can try (1) the development
version of lme4 (install from r-forge, but it might be broken right
now ...); (2) glmmADMB ...

  ... but I would probably suggest lme for now.



More information about the R-sig-ecology mailing list