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/