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

# Re: st: repeated factor ANOVA

 From Philip Ender To statalist@hsphsun2.harvard.edu Subject Re: st: repeated factor ANOVA Date Tue, 2 Oct 2012 07:57:52 -0700

```On 10/2/2012 James prince <jsprince26@gmail.com> wrote:

Hello,

I am unsure how to set-up the following problem using the ANOVA
command. Any help would be appreciated.

I have data on 600 liver patients, 300 assigned to one of two
treatment groups (TREAT).
Each had 4 biopsy (one in each quadrant: UR, UL, LR, LL) and the
concentration on an enzyme (Y) measured. I also have data for sex. I
know that I can used XTMIXED to do this, but I need to use ANOVA

Thank you in advance,
Jim

--------------------------------------------------------------------------------------

This is what I did:  I first tried using a repeated ANOVA but got an error:

. anova y treat liver sex subj, repeat(subj)
could not determine between-subject error term; use bse() option

Then,
If I set it up as nested, I get a result, but I am not sure if it is correct.
anova y treat liver sex/ subj|liver/ ...

You say you need to use -anova- but you don't say why you need to use
-anova-.  For balanced designs -xtmixed- and -anova- yield equivalent
results although somewhat differnt p-values due to chi-square vs
F-ratio.  If the design is unbalance within subject then -xtmixed- is
much better.  With your large sample size the p-value issue should be
moot.

All that aside, here is the -anova- code to run your analysis without
sex.  The error term for treat is subj|treat.  There should be a treat
by liver interaction and the repeated factor is liver.

anova y treat  / subj|treat liver  treat#liver /, repeat(liver)

If you want to include sex you need to treat it as a between subject
factor.  The error term for the between subject factors is
subj|treat#sex.  You also get more interactions

anova y treat sex treat#sex / subj|treat#sex liver sex#liver
treat#liver sex#treat#liver /, repeat(liver)

-xtmixed- code is much simpler:

xtmixed y treat##sex##liver || subj:, reml var

--
Phil Ender
UCLA Statistical Consulting Group
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```