Skip to content
Prev 12938 / 20628 Next

lme4: Parameter contrasts?

Tom Carpenter wrote:
There are at least four options:

the multcomp package
estimable() in the gmodels package
the lsmeans package
the contrast package

Some of these work with nlme models (lme and/or gls) and some with lme4 models, and some with both (and with other type of models, e.g. GEE models). Some of them can adjust for multiple comparisons. They all give slightly different answers, even when not adjusting for multiple comparisons. I think this is mostly related to treating the degrees of freedom differently:

multcomp uses asymptotic tests (?infinite? degrees of freedom, z-tests) for everything except normal linear (non mixed-effects models), where it uses ordinary t-tests. (It even uses z-tests for gls models, though I think this shouldn?t be necessary.) It has excellent support for adjusting for multiple comparisons, in a variety of ways.

estimable() uses the *minimum* of the degrees of freedom of the parameters of the chosen contract when testing and constructing confidence intervals.

lsmeans uses asymptotic tests for lme(r) models, but calculates the correct (?) degrees of freedom for gls and lm objects. (In a simple gls example I tested, it seemed to sum the degrees of freedom.) It also supports the multcomp package.

contrast calculates degrees of freedom for both lme and gls models. However, the calculated degrees of freedom seems to differ between what I believe should basically be equivalent lme and gls models (e.g., a two time-point longitudinal gls model with compound symmetry and a mixed effects model with a random intercept for subject).