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 Jared Saletin <[email protected]> To [email protected] Subject Re: st: Xtmixed specification for rmANOVA with 2 within-subject factors Date Tue, 5 Apr 2011 22:15:09 -0700

```Hi Dave,

Thanks for the response!

And thanks for the tip on anovalator! I've recently started using it, and very much enjoy it!

I do have the book you mention, and have found it particularly useful in expanding my understanding of LMMs.

I'm still finding myself having a remaining issue though.

In the book, the rat-brain example would suggest that with two within-subject factors a model such as this would suffice :

xtmixed y  b##c | s:, var

--

I was mainly then confused by the UCLA page here:

http://www.ats.ucla.edu/stat/stata/faq/margins_mixed_anova.htm

Where for a split-plot design with two within-subject factors (along with a between-subject factor) the authors use the crossed-random factor model:

e.g.  xtmixed y a##b##c || _all: R.bs || _all: R.cs || _all: R.bcs || s:, var

I'm mainly confused as to why in this instance of a split-plot (with 2 within subject factors), but neither in the rat-brain totally within-subjects example from the book nor the first split-plot model presented on the UCLA page (1 between subject factor, 1 witihin-subject factor), are the the within-subject factors now considered crossed random-effects.

I haven't been able to reconcile the different approaches, even after reading the chapter from the book.

Thanks again!
Jared

On Apr 5, 2011, at 1:13 PM, Airey, David C wrote:

> .
>
> 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/

*
*   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/
```