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

# RE: Re:Re: Re: st: How do I run a 3-way repeated ANOVA?

 From "RAMPL Linn" To Subject RE: Re:Re: Re: st: How do I run a 3-way repeated ANOVA? Date Mon, 22 Mar 2010 14:28:36 +0100

```>Linn,

>Can you check your data set with these commands and report back?
Thanks.

>anova y s a/s#a  b/s#b c/s#c a#b/s#a#b  a#c/s#a#c  b#c/s#b#c a#b#c/,
>repeated(a b c)
>xtmixed y a##b##c || s: || s:R.a || s:R.b || s:R.c

>anovalator a b c, main fratio
>anovalator a b, two fratio
>anovalator a c, two fratio
>anovalator b c, two fratio
>anovalator a b c, 3way fratio

>anova y s a##b##c , repeated(a b c)
>xtmixed y a##b##c || s:

>anovalator a b c, main fratio
>anovalator a b, two fratio
>anovalator a c, two fratio
>anovalator b c, two fratio
>anovalator a b c, 3way fratio

Dear David,

1.) The first 3-way anova command I cannot run, since matsize is too
small (in my version I already set the max of 800) and although I
dropped empty cells and my factors have only 2 levels each. Anyone knows
what I could do?

2.) The second command

xtmixed y a##b##c || s: || s:R.a || s:R.b || s:R.c

yields the following
(Frequency = a, trial_2 = b, laten_product_type = c, matlab_file = s):

------------------------------------------------------------------------
----rt_laten |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------
----1.frequency|  -335.4941     105.84    -3.17   0.002   -542.9367
-128.0516
1.trial_2 |  -211.8647   108.0537    -1.96   0.050     -423.646
-.0833961

frequency#|
trial_2 |
1 1  |   363.0471   149.6803     2.43   0.015     69.67901
656.4151

1.laten_pr~e|   1690.373   115.1755    14.68   0.000  1464.634
1916.113

frequency#|
laten_prod~e|
1 1 |  -1450.713   154.5007    -9.39   0.000    -1753.529
-1147.898

trial_2#|
laten_prod~e |
1 1  |  -1420.303   154.2353    -9.21   0.000    -1722.598
-1118.007

frequency#|
trial_2#|
laten_prod~e |
1 1 1  |   1235.996   215.1155     5.75   0.000     814.3772
1657.614

_cons |   1911.329    87.8797    21.75   0.000     1739.088
2083.57
------------------------------------------------------------------------
----

. anovalator frequency trial_2 laten_product_type, main fratio

anovalator main-effect for frequency
chi2(1) = 112.46737   p-value = 2.823e-26
scaled as F-ratio = 112.46737

anovalator main-effect for trial_2
chi2(1) = 55.329868   p-value = 1.019e-13
scaled as F-ratio = 55.329868

anovalator main-effect for laten_product_type
chi2(1) = 89.046871   p-value = 3.856e-21
scaled as F-ratio = 89.046871

. anovalator frequency trial_2, two fratio

anovalator two-way interaction for frequency#trial_2
chi2(1) = 83.194467   p-value = 7.437e-20
scaled as F-ratio = 83.194467

. anovalator frequency laten_product_type, two fratio

anovalator two-way interaction for frequency#laten_product_type
chi2(1) = 59.939065   p-value = 9.784e-15
scaled as F-ratio = 59.939065

. anovalator trial_2 laten_product_type, two fratio

anovalator two-way interaction for trial_2#laten_product_type
chi2(1) = 55.653241   p-value = 8.645e-14
scaled as F-ratio = 55.653241

. anovalator frequency trial_2 laten_product_type, 3way fratio

anovalator 3-way interaction for frequency#trial_2#laten_product_type
chi2(1) = 33.013427   p-value = 9.152e-09
scaled as F-ratio = 33.013427

3.) The third command

anova y s a##b##c , repeated(a b c)

yields the following
(Frequency = a, trial_2 = b, laten_product_type = c, matlab_file = s):

Source |  Partial SS    df       MS           F     Prob > F

----------------------+-------------------------------------------------
-
Model |   350298338    91  3849432.29       7.64     0.0000
|
matlab_file |   140852038    84  1676809.98       3.33     0.0000
frequency |  53661693.5     1  53661693.5     106.45     0.0000
trial_2 |  30999754.2     1  30999754.2      61.49     0.0000
frequency#trial_2 |  39706885.9     1  39706885.9      78.76
0.0000
laten_pro~e |  52802044.5     1  52802044.5     104.74
0.0000
frequency#laten_pro~e |  28618795.1     1  28618795.1      56.77
0.0000
trial_2#laten_pro~e |  26815444.4     1  26815444.4      53.19
0.0000
frequency#trial_2# |
laten_pro~e |  15776930.6     1  15776930.6      31.30
0.0000

Residual |   288357651   572  504121.767

----------------------+-------------------------------------------------
-
Total |   638655989   663  963282.035

. anovalator frequency trial_2 laten_product_type, main fratio

anovalator main-effect for frequency
chi2(1) = 106.4459   p-value = 5.888e-25
scaled as F-ratio = 106.4459

anovalator main-effect for trial_2
chi2(1) = 61.492592   p-value = 4.444e-15
scaled as F-ratio = 61.492592

anovalator main-effect for laten_product_type
chi2(1) = 104.74066   p-value = 1.392e-24
scaled as F-ratio = 104.74066

. anovalator frequency trial_2, two fratio

anovalator two-way interaction for frequency#trial_2
chi2(1) = 78.764474   p-value = 6.997e-19
scaled as F-ratio = 78.764474

. anovalator frequency laten_product_type, two fratio

anovalator two-way interaction for frequency#laten_product_type
chi2(1) = 56.769608   p-value = 4.900e-14
scaled as F-ratio = 56.769608

. anovalator trial_2 laten_product_type, two fratio

anovalator two-way interaction for trial_2#laten_product_type
chi2(1) = 53.192395   p-value = 3.024e-13
scaled as F-ratio = 53.192395

. anovalator frequency trial_2 laten_product_type, 3way fratio

anovalator 3-way interaction for frequency#trial_2#laten_product_type
chi2(1) = 31.295873   p-value = 2.216e-08
scaled as F-ratio = 31.295873

4.) The fourth command

xtmixed y a##b##c || s:

yields the following
(Frequency = a, trial_2 = b, laten_product_type = c, matlab_file = s):

------------------------------------------------------------------------
----
rt_laten |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+----------------------------------------------------------
----
1.frequency |  -335.4941   108.9435    -3.08   0.002  -549.0194
-121.9688
1.trial_2 |  -211.8647   108.9435    -1.94   0.052    -425.39
1.660584

frequency#|
trial_2 |
1 1  |   363.0471   154.0693     2.36   0.018      61.0767
665.0174

1.laten_pr~e |   1684.502   115.1668    14.63   0.000   1458.78
1910.225

frequency#|
laten_prod~e |
1 1  |  -1445.588   158.7853    -9.10   0.000    -1756.801
-1134.375

trial_2#|
laten_prod~e |
1 1  |  -1414.432    158.531    -8.92   0.000    -1725.147
-1103.717

frequency#|
trial_2#|
laten_prod~e |
1 1 1  |    1230.87   221.2467     5.56   0.000     797.2348
1664.506

_cons |   1911.329   87.82307    21.76   0.000     1739.199
2083.459
------------------------------------------------------------------------
----

. anovalator frequency trial_2 laten_product_type, main fratio

anovalator main-effect for frequency
chi2(1) = 105.8431   p-value = 7.981e-25
scaled as F-ratio = 105.8431

anovalator main-effect for trial_2
chi2(1) = 60.399831   p-value = 7.742e-15
scaled as F-ratio = 60.399831

anovalator main-effect for laten_product_type
chi2(1) = 103.32856   p-value = 2.839e-24
scaled as F-ratio = 103.32856

. anovalator frequency trial_2, two fratio

anovalator two-way interaction for frequency#trial_2
chi2(1) = 78.236995   p-value = 9.139e-19
scaled as F-ratio = 78.236995

. anovalator frequency laten_product_type, two fratio

anovalator two-way interaction for frequency#laten_product_type
chi2(1) = 56.314778   p-value = 6.175e-14
scaled as F-ratio = 56.314778

. anovalator trial_2 laten_product_type, two fratio

anovalator two-way interaction for trial_2#laten_product_type
chi2(1) = 52.173862   p-value = 5.080e-13
scaled as F-ratio = 52.173862

. anovalator frequency trial_2 laten_product_type, 3way fratio

anovalator 3-way interaction for frequency#trial_2#laten_product_type
chi2(1) = 30.950733   p-value = 2.647e-08
scaled as F-ratio = 30.950733

So obviously, the last two commands do produce slightly different
results regarding the F-ratios. Why would that be, since they should
model the same?

I am not sure, if I got the difference between the first two and the
last two right?

Thank you so much for your help!!

Linn

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