# RE: st: Re: ancova for repeated designs

 From tmmanini To Statalist Subject RE: st: Re: ancova for repeated designs Date Mon, 16 Aug 2004 00:25:12 -0400

```You have all been very helpful, thank you.  You are right that I have only 6
levels of convariate (a
possible problem), but I took your advice on several fronts and I'm still not
fully comprehending the
solution.  Here's what I did: (I used my data with 32 subjects, which is
included at the end).

First I ran the model positioning g after the id|g random error term, and the
specifying if t>1.  I got a
sig. interaction, but according a recent addition to the listserv, I learned
that this interaction may not be
as important as I once thought.  Therefore, I dropped the g*t term from the
model.
anova y g / id|g x g*x t g*t if t>1, rep(t) cont(x)

Number of obs =      64     R-squared     =  0.8051
Root MSE      = 1.25373     Adj R-squared =  0.5767

Source |  Partial SS    df       MS           F     Prob > F
-----------+----------------------------------------------------
Model |  188.354167    34  5.53982843       3.52     0.0004
|
g |  .321850082     2  .160925041       0.07     0.9337
id|g |  60.8061356    26  2.33869752
-----------+----------------------------------------------------
x |  5.33333333     1  5.33333333       3.39     0.0757
g*x |  10.6666667     2  5.33333333       3.39     0.0474
t |  22.0119048     1  22.0119048      14.00     0.0008
g*t |  2.16666667     2  1.08333333       0.69     0.5100
|
Residual |  45.5833333    29  1.57183908
-----------+----------------------------------------------------
Total |    233.9375    63  3.71329365

g*x dropped from the model

anova y g / id|g x t g*t if t>1, rep(t) cont(x)

Number of obs =      64     R-squared     =  0.8051
Root MSE      = 1.25373     Adj R-squared =  0.5767

Source |  Partial SS    df       MS           F     Prob > F
-----------+----------------------------------------------------
Model |  188.354167    34  5.53982843       3.52     0.0004
|
g |  12.0364118     2  6.01820591       2.53     0.0977
id|g |  66.5887517    28   2.3781697
-----------+----------------------------------------------------
x |  2.7111e-28     1  2.7111e-28       0.00     1.0000
t |  22.0119048     1  22.0119048      14.00     0.0008
g*t |  2.16666667     2  1.08333333       0.69     0.5100
|
Residual |  45.5833333    29  1.57183908
-----------+----------------------------------------------------
Total |    233.9375    63  3.71329365

These results seemed weird, based on the previous F value for x being much
higher.  So I dropped t>1
from the model

anova y g / id|g x t g*t, rep(t) cont(x)

Number of obs =      96     R-squared     =  0.7789
Root MSE      = 1.18014     Adj R-squared =  0.6379

Source |  Partial SS    df       MS           F     Prob > F
-----------+----------------------------------------------------
Model |  284.628472    37  7.69266141       5.52     0.0000
|
g |  8.02427455     2  4.01213727       2.53     0.0977
id|g |  44.3925011    28  1.58544647
-----------+----------------------------------------------------
x |  .166666667     1  .166666667       0.12     0.7306
t |   34.015873     2  17.0079365      12.21     0.0000
g*t |  5.63888889     4  1.40972222       1.01     0.4087
|
Residual |  80.7777778    58  1.39272031
-----------+----------------------------------------------------
Total |   365.40625    95  3.84638158

I'm not sure which model it correct?  Based on recent addition by Joseph
Coveney, the last model
(without t>1) would be correct.

Here is the data, sorry it is long, there are 32 subjects, 3 levels of g, 3
levels of t and 1 level of x
(remeber x is the first level of t (time)) I'm trying to covary for the
pre-test level (time==1).  One more
thing, I successfully implemented the adjust command by included id in the
"by" statement.  However, I
only received adjustments for those subjects I specify (ie. id<=4 gives me
subjects 1 through 3), which
makes sense.  However, I would like to report the adjusted mean for each group
over each time period.
I guess I can request all id's be shown on the output by using "adjust x, by(g
t id)" and then taking the
mean of the id's for each group, but that seems cumbersome.  Is there a better
way?  By the way thank
you again for all your help.

id	g	t	y	x
1	1	1	1	1
1	1	2	1	1
1	1	3	1	1
2	2	1	1	1
2	2	2	1	1
2	2	3	1	1
3	3	1	5	5
3	3	2	5	5
3	3	3	1	5
4	2	1	5	5
4	2	2	4	5
4	2	3	1	5
5	3	1	6	6
5	3	3	6	6
5	3	2	6	6
6	1	1	3	3
6	1	2	3	3
6	1	3	3	3
7	1	1	6	6
7	1	2	6	6
7	1	3	6	6
8	1	1	1	1
8	1	2	1	1
8	1	3	1	1
9	2	1	5	5
9	2	2	6	5
9	2	3	1	5
10	1	1	1	1
10	1	2	1	1
10	1	3	1	1
11	1	1	4	4
11	1	2	4	4
11	1	3	1	4
12	2	1	2	2
12	2	2	2	2
12	2	3	2	2
13	2	1	5	5
13	2	2	1	5
13	2	3	1	5
14	1	1	1	1
14	1	2	1	1
14	1	3	1	1
15	1	1	5	5
15	1	2	5	5
15	1	3	1	5
16	3	1	1	1
16	3	2	1	1
16	3	3	1	1
17	1	1	6	6
17	1	2	6	6
17	1	3	6	6
18	2	1	2	2
18	2	2	2	2
18	2	3	1	2
19	3	1	4	4
19	3	2	4	4
19	3	3	2	4
20	2	1	1	1
20	2	2	1	1
20	2	3	1	1
21	1	1	6	6
21	1	2	6	6
21	1	3	1	6
22	3	1	6	6
22	3	2	6	6
22	3	3	1	6
23	2	1	1	1
23	2	2	1	1
23	2	3	1	1
24	2	1	5	5
24	2	2	5	5
24	2	3	4	5
25	2	1	5	5
25	2	2	1	5
25	2	3	1	5
26	2	1	2	2
26	2	2	1	2
26	2	3	1	2
27	3	1	2	2
27	3	2	2	2
27	3	3	1	2
28	2	1	1	1
28	2	2	1	1
28	2	3	1	1
29	1	1	1	1
29	1	2	1	1
29	1	3	1	1
30	3	1	3	3
30	3	2	3	3
30	3	3	3	3
31	1	1	2	2
31	1	2	5	2
31	1	3	5	2
32	3	1	4	4
32	3	2	4	4
32	3	3	2	4

>===== Original Message From Joseph Coveney <jcoveney@bigplanet.com> =====
>An example of a time-invariant repeated measures ANCOVA is shown below.  It
>is from B. J. Winer, D. R. Brown and K. M. Michels, _Statistical Principles
>in Experimental Design_ Third Edition (New York: McGraw-Hill, 1991),
>pp.828-832.  The do-file reproduces the results in the text within rounding
>error (and after correcting a typographical error in the text in
>Table 10.34).
>
>As I mentioned yesterday in a manner that was incomprehensibly articulated
>("there is no variation of x within id, so there won't be any within the
>id|g error term, either, and it should be put to the right of the id|g
>random error term"?), the continuous covariate shouldn't share the
>within-subjects error term with the between-subjects factor, and should be
>moved to the right of the id|g term.  Winer's example does not include a
>term for the covariate-by-between-groups-factor interaction.  For most
>purposes, between-group homogeneity of the slope of the continuous covariate
>is assumed, since its violation probably couldn't be powerfully detected by
>the statistical significance of the interaction term for most datasets not
>specifically powered to examine the interaction.
>
>Joseph Coveney
>
>clear
>set more off
>input byte subj byte a byte x1 byte y1 byte x2 byte y2
>1 1  3 10  3  8 // Note typographical error in text's Table 10.34
>2 1  5 15  5 12
>3 1  8 20  8 14
>4 1  2 12  2  6
>5 2  1 15  1 10
>6 2  8 25  8 20
>7 2 10 20 10 15
>8 2  2 15  2 10
>end
>reshape long x y, i(subj) j(b)
>/* Unadjusted repeated-measures ANOVA--Part (i) of Table 10.35
>   on Page 830 */
>anova y a / a|subj b a*b, repeated(b)
>/* Repeated-measures ANCOVA--Part (ii) of Table 10.35 */
>anova y a / a|subj x b a*b, repeated(b) continuous(x)
>adjust x if subj==1 | subj==5, by(a b subj)
>exit
>
>
>
>
>
>*
>*   For searches and help try:
>*   http://www.stata.com/support/faqs/res/findit.html
>*   http://www.stata.com/support/statalist/faq
>*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```