Wednesday, November 16, 2005
Re: st: time-effect in manova (anova with repeated measures )
> Maren Kandulla wrote: > > again I am fighting with stata to do the right analysis. My data is a panel > design, 6 measuring times, 4 groups to compare, n=75. > I try to test whether 4 different groups differ in terms of means over time > regarding a variable (motivation). In other words wether motivation differs > between the 4 groups and wether there is a change over time (motivation is > decreasing f.e.). First I did a nice graph to see the differences but now I > would like to test them using manova. > I did a manova (for repeated measures) > manova motiva_1 motiva_2 motiva_3 motiva_4 motiva_5 motiva_6 = group > Then I checked, which of the 4 groups differ significantly. > [omitted] > This worked out perfectly. > > 1.) However, now I would like to see, wether there is a over-all time-effect > (wether motivation is decreasing or increasing over time) for all groups > together and for each group. This is very easy in SPSS but I did not figure > it out in Stata even though I read different manuals and books. > 2.) Secondly I would like to see wether there is a significant difference > between two groups at a certain time-point (f.e. group 2 and 4 at time 3) . > I could do this by using a simple anova but maybe I can integrate it in the > manova-model as well? > 3.) Thirdly I would like to know wether a decrease for one group differ from > a certain increase of another group between two time-points (f.e. wether the > decrease of group 4 between time 2 and time 3 differes significantly from > the increase of group 1 at the same time period. > > Could you please tell me, how to write the matrix for it. I just did not > understand it by reading the manual or other books. Question 1 is the most > important. I know I could do Question 2 and 3 by using a form of > panelanalysis, but since I am working with psychologist I would rather go > for anova with repeated measures. > > -------------------------------------------------------------------------- ------ > > No one else seems to have taken you up, so I'll give it a try. > > 1.) The design matrix in Stata's -manova- is overparameterized like that in > SAS's PROC GLM or SPSS's GLM. To get the mean of the groups at a given > time, you take _b[_cons] and add the average of the group coefficients. > (See the -lincom- statement in the do-file below). So, to test the time > effect, you need to test this mean across time: the one-row test matrix > will have a one in the constant's column (the first column), and (with equal > group sizes) one-quarter in each of your four groups' columns. This is > illustrated in the do-file below, which uses a dataset from UCLA's Academic > Technology Services' Statistical Computing Resources website. The Web page > is www.ats.ucla.edu/stat/sas/library/comp_repeated.htm and you can compare > Stata's results from the do-file below for the main effects for time (and > the group-by-time interaction) to those in the SAS listing shown on the Web > page. Note that the example dataset from the website has only three > treatment groups, and not four as in your case, so the illustration below > divides the sum of the coefficients by three in order to get the average, > and not four. > > 2.) A one-row M matrix with a one for the column for Time 3 and zeroes > elsewhere, and then a one-row test matrix with a one for the column for > Group 3 and a minus one for the column for Group 4 and zeroes elsewhere. > (See do-file below.) > > 3.) Analogous to 2.), a one in the column for Time 2 a minus one for Time 3 > and zeroes elsewhere, a one for Group 1 and a minus one for Group 4 and > zeroes elsewhere. (See do-file below--the example dataset has only three > groups, so in the illustration, I substituted Group 3 for your Group 4.) > > With 75 people and four groups, you will have unequal representations among > groups. I think that MANOVA does best with equal representation among > groups, just like factorial ANOVA does. At the least, you might need to > adjust the one-quarter to some group-size-weighted fraction in order to get > the -lincom- estimate to match that by -summarize-. I recall B. J. Winer > recommending harmonic means in the context of unbalanced ANOVA in order to > get a better estimate of the cell's contribution to the pooled variance. > This might be worthwhile to look into, depending upon the magnitude of the > imbalance. (Probably not if it's 19, 19, 19 and 18.) > > For simple main effects testing involving the repeated measurements in the > context of repeated-measures ANOVA in which the sphericity assumption is on > shakey grounds, David Nichols (see the two postings under the subject > heading "Post-hoc tests" at > http://socsci.colorado.edu/LAB/STATS/SPSS/spss195.html ) suggests using > paired Student t-tests. He mentions that the contrasts can be set up in > SPSS's MANOVA command (which takes advantage of the pooled between-group > error), but it is usually easier to do a paired t-test and accept some loss > of power. In the example below, the p-values were similar (essentially the > same, actually) whether the test was done in -manova- or by -ttest-. The > problem of unbalanced groups goes away with paired Student's t-tests, too. > > Joseph Coveney > > infile id cond ib1 ib2 ib3 ib4 ib5 /// > ms1 ms2 ms3 ms4 ms5 sr1 sr2 sr3 sr4 sr5 /// > using /// > http://www.ats.ucla.edu/stat/mult_pkg/library/repeat/repeat.txt > compress > tabulate cond > // Three treatment groups, balanced > manova sr1 sr2 sr3 sr4 sr5 = cond > * > * Orientation to -manova-'s parameterization > * > summarize sr1 > // Compare that mean to: > lincom [sr1]_b[_cons] + ([sr1]_b[cond[1]] + /// > [sr1]_b[cond[2]] + [sr1]_b[cond[3]]) / 3 > // So, in order to track the mean across time, > // the test matrix is 1 1/3 1/3 1/3 > * > * Main effects of time > * > matrix M = (1, -1, 0, 0, 0 \ 0, 1, -1, 0, 0 \ /// > 0, 0, 1, -1, 0 \ 0, 0, 0, 1, -1) > matrix H = (1, `=1/3', `=1/3', `=1/3') > manovatest , test(H) ytransform(M) > // Cf. SAS results presented in Web page > * > * Group-by-time interaction (lagniappe) > * > matrix H = (0, 1, -1, 0 \ 0, 0, 1, -1) > manovatest , test(H) ytransform(M) > // Cf. SAS results presented in Web page > * > * Group 2 versus Group 3 at Time 3 > * > matrix M = (0, 0, 1, 0, 0) > matrix H = (0, 0, 1, -1) > manovatest , test(H) ytransform(M) > ttest sr3 if inlist(cond, 2, 3), by(cond) > * > * Change from Times 2 to 3 between Groups 1 and 3 > * > matrix M = (0, 1, -1, 0, 0) > matrix H = (0, 1, 0, -1) > manovatest , test(H) ytransform(M) > generate delta23 = sr2 - sr3 > ttest delta23 if inlist(cond, 1, 3), by(cond) > exit >
Dear Joseph, thanks a lot for this brilliant do-file! I checked it on my data and it worked out perfectly AND finally I understood the matrix-test-systematic, what makes me very happy. However, I do have one request regarding your remark: > With 75 people and four groups, you will have unequal representations among > groups. I think that MANOVA does best with equal representation among > groups, just like factorial ANOVA does. At the least, you might need to > adjust the one-quarter to some group-size-weighted fraction in order to get > the -lincom- estimate to match that by -summarize-.
I have a very unbalanced design. To be more precise than in my previous email where I "combined information", I have following n-distribution: 1. Cohort with 4 groups: 21, 14, 35, 17; total 87 and 2. Cohort with 3 groups: 35, 21, 19; total 75; cohorts are analysed seperately. In the Stata-Manual I found following information: > manova fits multivariate analysis-of-variance (MANOVA) and multivariate analysis-of-covariance (MANCOVA) models for balanced and unbalanced designs...
I therefore decided not to do any adjustment. Please, correct me if this was wrong!
Thanks again for your help! Maren
* * 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/
Tag: statalist