You might try
and see whether that gets you where you want to go.
Code:
mixed c.age i.sex i.trt##i.week || pid: , reml dfmethod(satterthwaite)
version 14.2 clear * set more off set seed 1384471 quietly set obs 52 generate byte pid = _n generate double u = rnormal() generate byte sex = mod(_n, 2) generate byte age = runiformint(18, 65) bysort sex (pid): generate byte trt = mod(_n, 2) quietly expand 2 bysort pid: generate byte week = _n - 1 generate double y = u + rnormal() * * Begin here * /* Repeated-measures ANCOVA using -mixed- (Suggested in post immediately above in this thread) */ mixed y c.age i.sex i.trt##i.week || pid: , reml dfmethod(satterthwaite) nolrtest nolog // Tests of ANOVA main effects (i.e., ANOVA parameterization of main-effects contrasts) contrast trt, small contrast week, small contrast sex, small /* Repeated-measures ANCOVA using -anova- 1. As per previous posts in this thread, ignore the test of the age covariate) 2. Also, -repeated(week)- is not needed here because there are only two levels of the week factor */ anova y c.age sex trt / sex#trt|pid week trt#week // To test age covariate (if you really care): * Either using -xtreg , be- xtreg y c.age i.sex i.trt##i.week, i(pid) be * (Side note: see also the following for repeated-measures factors) xtreg y c.age i.sex i.trt##i.week, i(pid) fe contrast week // (Again, ANOVA parameterization of main-effects contrast) * or using -manova- followed by -manovatest- quietly reshape wide y, i(pid) j(week) quietly manova y0 y1 = c.age i.sex i.trt matrix define M = J(1, 2, 1) manovatest , showorder matrix define A = (1, 0, 0, 0, 0, 0) manovatest , test(A) ytransform(M) exit
Comment