# [R-sig-ME] Linear mixed effect model

Ben Bolker bbolker at gmail.com
Sat Mar 19 16:07:55 CET 2011

```On 11-03-19 10:47 AM, Manuel Spínola wrote:
> Hi Ben and other list members,
>
> I looked at the residuals and log transforming the gave me
> heteroscedasticity, so I don't know if I need to transform.
>
> Is statistically appropriate to fit different models, lienear, gls, lme
> and compare them with AIC?
>
>  mod1 = lm(Swiftness.1 ~ Lure + Sex + Facility.Size, data = otter)
> mod2 = gls(Swiftness.1 ~ Lure + Sex + Facility.Size, data = otter)
> mod3 = gls(Swiftness.1 ~ 1, data = otter)
> mod4 =  lme(Swiftness.1 ~ Lure + Sex + Facility.Size, random =
> ~1|Subject, data = otter)
>
>> AICctab(mod1, mod2, mod3, mod4, weights = T, delta = TRUE, base = T,
> sort = TRUE, nobs = 17)
>                AICc       df    dAICc   weight
> mod2    1276.4   10    0.0        1
> mod4   1294.5   11   18.1      <0.001
> mod3   1302.9     2    26.6     <0.001
> mod1   1356.3  10     80.0    <0.001
>

A few thoughts:

* you can in principle compare various models (including those
with/without random effects), but it is a crude approximation for
several reasons (boundary issues with random effects, marginal vs
conditional AIC, etc. -- see <http://glmm.wikidot.com/faq> for more
discussion).

* Take a look at very recent discussions on this list about comparing lm
vs gls vs lme; in particular make sure you have REML=TRUE/FALSE set
appropriately.  As you have done it, the fits may not be comparable.

* I think you should retain the random effect of 'otter' in any case
because it is a natural part of the experimental design (although I
think that if you correctly set REML=FALSE you will get identical
likelihoods between gls and lme, and gls will appear better because it
is missing a random-effect variance parameter)

```