[R-sig-ME] Differences in degrees of freedom between a mixed-effects model and a gls model using nlme

Ben Bolker bbolker at gmail.com
Mon Feb 9 05:36:11 CET 2015


Ken Beath <ken.beath at ...> writes:

> 
> All 3 (paired t-test, mixed effect and gls with compound symmetry) are
> fitting the same model, and so should give the same result. That is what
> you see with the first example. The gls model is not getting it wrong
> except for the df.
> 
> For the second the 3 model results should again be the same. I'm not
> certain why but it may be numerical. Even though the data come 
> from a model
> that isn't correct for the fitting that should be irrelevant, it is the
> data that produce the model fit not the model that produces the data.
> Possibly estimates of the correlation are poor when there is little
> correlation, and that flows through to the mixed effects and 
> gls results.
> 
> The relationship to the unpaired t-test is probably irrelevant. Note also
> that the default for the t.test is unequal variances whereas for a mixed
> model it is equal variances.
> 
> The df for gls is obviously in a sense a bug. Getting the df for a mixed
> model isn't easy. Here we have a nice simple correlation structure and
> there is an obvious correct answer, but usually there isn't one. If the
> model assumed uncorrelated data then the gls df would be correct, so it is
> necessary for the software to work out what is going on. Using parametric
> bootstrapping to determine the underlying distribution seems a better
> method if accuracy is important.
> 
> Ken
> 

  For what it's worth you can easily see what gls() is doing to
get its df, and confirm that it's naive, by printing nlme:::summary.gls:

  tTable[, "p-value"] <- 2 * pt(-abs(tTable[, "t-value"]), 
        dims$N - dims$p)

For what it's worth, I've found that the df calculations used by
lme() often fail quite badly for random-slopes models ... it's often
really hard to guess, even for simpler designs (i.e. where there
really is a precise correspondence with an F distribution -- no correlation
structures or lack of balance or crossed random effects).



More information about the R-sig-mixed-models mailing list