[R-sig-ME] announcing package afex: obtain p-values for all fixed effects in a lmer() model via KRmodcomp
Henrik Singmann
henrik.singmann at psychologie.uni-freiburg.de
Fri Aug 10 01:21:15 CEST 2012
Dear list members,
I am happy to announce that my new package "afex" has been accepted on
CRAN that may be of interest to some.
In particular, it contains the function mixed() that calculates p-values
for all fixed effects (terms) in a mixed model using the Kenward-Rogers
approximation for degrees of freedom implemented in pbkrtest::KRmodcomp
(after fitting all the necessary models for this using lme4::lmer).
In the current version (0.2-26, the last number denotes the r-forge
revision it is based on) mixed() only allows to obtain type 3 tests, but
future versions will allow type 2 tests (chances are that within August
the type 2 tests will be implemented in the development version on
R-Forge). The type 3 tests are based on comparing a model in which only
the term of interest is eliminated with the full model. This
functionality is based on a helpful discussion with Ben Bolker and
Joshua Wiley on http://stackoverflow.com/q/11335923/289572.
Furthermore, the random-effects structure is identical for all models.
This design decision seems debatable to me and I am happy for any input.
An alternative would be to delete the term of interest also from the
random-effect structure (and not only from the fixed-effects structure)
when fitting the contrasting model. However, I am neither sure if this
is possible with KRmodcomp nor if it is a sensible thing to do.
Running mixed() may be a lengthy process as it fits the full model and
an additional model for each term in the model (including the intercept)
with the full random structure using lmer(). Furthermore, obtaining the
p-values via KRmodcomp is also a time consuming process.
Note that loading package afex sets the default contrasts to contr.sum.
For a brief description of afex see below or
http://cran.r-project.org/web/packages/afex/index.html.
I hope mixed() may be helpful and am interested in any discussion,
questions, ideas, bugs, or contributions.
Best,
Henrik
afex – Analysis of Factorial Experiments
afex was developed for the analysis of factorial experiments and
provides convenience functions for type 3 (the default) and type 2 tests
for ANOVA and ANCOVA (using car::Anova) and mixed models (using lmer).
It is set up in a way (type 3 tests as defaults and setting contrasts to
contr.sum) to replicate results from commercial software packages with
the hope to ease the transition from such software to R. Additionally,
afex has a formula interface for car::Anova imitating the functionality
of aov (but works with unbalanced designs, see ?aov.car). Data for afex
needs to be in the long format (i.e., one observation per row). afex
has a homepage (that currently only focuses on the ANOVA and ANCOVA
functionality):
http://www.psychologie.uni-freiburg.de/Members/singmann/R/afex
The design of afex was strongly influenced by Mike Lawrence’ ez package.
--
Dipl. Psych. Henrik Singmann
PhD Student
Albert-Ludwigs-Universität Freiburg, Germany
http://www.psychologie.uni-freiburg.de/Members/singmann
More information about the R-sig-mixed-models
mailing list