Comments (2)
I do not agree. The Orthodont
data is special in the sense that it has a repeated-measures variable, but no replicates for each cell of the design and unit of observation. This is data that is traditionally analyzed with ANOVAs, but can also be analyzed with mixed models, but not perfectly. We usually would want to estimate random slopes for the effect of age
for the Subject
random intercept, but because of the absence of replicates, the random slopes are not identified. So in principle, the correct mixed model formula would indeed be (assuming age
is a factor): distance ~ age + (age|Subject)
.
However, given that we have no replicates, the random intercept model seems indeed the most appropriate, as I have discussed here: http://singmann.org/mixed-models-for-anova-designs-with-one-observation-per-unit-of-observation-and-cell-of-the-design/
So no, aov4
works exactly as it should. Within-subject factors should have something like a random slope in principle and that is what you have to specify. Furthermore, you need to somehow flag the within-subject factors. Note that the correct formula for aov
for this design is distance ~ age + Error(Subject/(age))
. Again, age
is put somehow in relationship to Subject
.
To sum this up, random intercept models are in principle dangerous, but somehow okay for this specific case.
from afex.
Many thanks for your quick response, and that article, both of which are really helpful in clarifying the problem.
I can see that, from the perspective of experimental data where repetitions are the norm, this problem might seem a bit odd. However this type of data (no replicates for each cell of the design and unit of observation) are actually quite common in applied settings where one might want to avoid traditional RM Anova for other reasons (e.g. because of missing or unbalanced data). The most common case in my experience would be a clinical trial with a single outcome and > 2 measurement occasions. It seems a shame that afex
, which does such a brilliant job of abstracting away some of the cruft of aov
for experimental data, can't also work in this context.
As a consequence I wonder, if nothing else, whether the afex help pages would benefit from a small clarification? Or, even better an amended error message when someone tries to specify (1 | grouping)
in aov_4
or fails to specify a random slope?
The issue is that, because aov4
is mimicking the syntax of lmer (described as 'lmer-like'), one might reasonably expect that either the pair of models I included above would be equivalent (they are not, and the aov4 call fails) or that the models below would be equivalent, when in fact the lmer model would fail (because as you point out it is non-identified):
aov_4(distance ~ age + (age | Subject), data=nlme::Orthodont)
lmerTest::anova(lmer(distance ~ factor(age) + (factor(age) | Subject), data=nlme::Orthodont)
The issue here is not the rights and wrongs of intercept-only mixed models, but rather the implied promise that aov4
will translate lmer
model formulae to an equivalent traditional RM anova. Inevitably this translation is not 1:1 because the underlying models are different - but I'd hate for anyone else to waste the time I have trying to work out why. If you'd like me to draft something I'd be happy to do so!
from afex.
Related Issues (20)
- Other suitable contrasts than contr.sum HOT 1
- error for running mixed() with a null model (no fixed effect) HOT 1
- Understanding inconsistencies between `aov_car()` and equivalents HOT 1
- Adding geoms to `afex_plot()` HOT 5
- Degree of Freedom in aov_car output HOT 3
- Can aov_car report 95% confidence interval? HOT 6
- Unexpected outcomes when setting contrasts manually HOT 3
- Anova table data heading incorrect HOT 2
- Issues with next version of ggplot2 HOT 2
- [Feature request] Add ability to automatically simplify mixed models following Singman and Kellen (2019)
- Residuals with `mixed`-fitted model HOT 3
- Issue with next version of ggbeeswarm HOT 1
- Bump minimum needed R version to `4.1` for `{pbkrtest}` update?
- Issue with upcoming ggplot2 version HOT 3
- [Sugestion] MMRM (GLS) for Afex: Kenward-Roger and Satterthwaite for free :) HOT 1
- Error in ctrl$optimizer <- optimizer[..i] : object of type 'symbol' is not subsettable
- emmeans gives wrong results for afex_aovs if the at = argument is reversed HOT 1
- Centering Covariate Still Throws Error HOT 5
- Printing method for `nice` collides with `rempsyc::nice_table()` of class `nice_table` HOT 2
- different residuals HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from afex.