Bookmark and Share

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: repeated factor ANOVA

From   Philip Ender <>
Subject   Re: st: repeated factor ANOVA
Date   Tue, 2 Oct 2012 07:57:52 -0700

On 10/2/2012 James prince <> wrote:


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,


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

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

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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index