Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# re: st: Xtmixed specification for rmANOVA with 2 within-subject factors

 From "Airey, David C" <[email protected]> To "[email protected]" <[email protected]> Subject re: st: Xtmixed specification for rmANOVA with 2 within-subject factors Date Tue, 5 Apr 2011 15:13:51 -0500

```.

I think chapter 5 in Linear Mixed Models: A Practical Guide Using Statistical Software (available in the Stata book store) covers this design with xtmixed. Note the book site online has updated their code over the years to keep up with version 11.

<http://www-personal.umich.edu/~bwest/almmussp.html>
<http://www-personal.umich.edu/~bwest/chapter5_stata_final.do>

WRT the final question, you should google the pages for help about Phil Ender's anovalator program and other materials on rmANOVA by him, as well as consider use of -margins-.

-Dave

>
> Dear Stata users and experts,
>
> I'm new to Stata and trying to learn xtmixed in a two-way within-subjects anova situation, and was hoping to ask a couple questions.
>
> I have an psychological experimental design measuring performance on a cognitive task "y" with two controlled within-subject factors:  b - 3 levels (repeated conditions), and c - 2 levels (task manipulation, e.g. memory for two different word-types during the task), with subjects coded "s".
>
> In an ANOVA setting I would typically do:
>
> (1) anova y s b / b#s c / c#s b#c, repeated(b c).
>
> We have some missing data for a few subjects, so I hoped to move to a mixed model analysis. However,  I'm slightly confused as to the proper model specification.
>
> Because both factors are experimentally controlled across subjects, I first presumed a random-intercept only model with fixed effects for a and b, and fit:
>
> (2) xi: xtmixed y b##c || s:, var.
>
> And then tested the effects of a, b, and a#b using the margins command (with asbalanced option, as the experiment was intended to be balanced), followed by tests of the main effects and interaction.
>
> However, I've noticed on the ucla page,  a similar design (except also with a between-subject factor a) using what I believe are crossed random-intercepts for b,c and the interaction, respectively:
>
> (3) xi: xtmixed y a##b##c || _all: R.bs || _all: R.cs || _all: R.bcs || s:, var.
>
> I was hoping that the stats and Stata experts here could help me decide which is the better alternative to the rmANOVA, the former simple random-intercept model (model #2), seems to made more immediate sense to me.
>
> Also, am I correct that to test the anova-style omnibus effects for b (or any factor), I would simply do: "margins b, post asbalanced" followed by "test (1.b=2.b=3.b)", for instance?
>
> --
>
> As a final question, and thank you for your patience,
>
> If I wanted to include a random-slope into the model for say factor b, and would typically adapted model (2) above to be:
>
> xi: xtmixed y b##c || s: b, var.
>
> How would I best do the same for crossed model (3)?
>
> Apologies if some of this is basic, I'm just attempting to integrate all my reading and find the ideal analyses.
>
> Thank you all for your help!
>
> Cheers,
> Jared Saletin

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```