help > 2-way rm ANOVA with more than 2 levels
Showing 1-2 of 2 posts
Sep 13, 2015 11:09 AM | Eckhard Schlemm
2-way rm ANOVA with more than 2 levels
Hi,
this question is similar in spirit to this question. I am looking for some guidance in setting up a design matrix for a two-way repeated measures ANOVA with one between-subject factor group (3 levels) and one within-subject factor time (3 levels).
I am assuming data in the order
Subject-1 Group-1 Time-1
Subject-2 Group-1 Time-1
Subject-3 Group-2 Time-1
Subject-4 Group-2 Time-1
Subject-5 Group-3 Time-1
Subject-6 Group-3 Time-1
Subject-1 Group-1 Time-2
Subject-2 Group-1 Time-2
Subject-3 Group-2 Time-2
Subject-4 Group-2 Time-2
Subject-5 Group-3 Time-2
Subject-6 Group-3 Time-2
Subject-1 Group-1 Time-3
Subject-2 Group-1 Time-3
Subject-3 Group-2 Time-3
Subject-4 Group-2 Time-3
Subject-5 Group-3 Time-3
Subject-6 Group-3 Time-3
I understand how to model the subject-specific means as individual random effects, but don't see how to code group, time and the interaction group x time. In the answer to the linked question, the two levels were coded by +1 und -1, (and the interaction by the respective product) but how would this be extended to more than two, e.g. three, levels?
Many thanks,
Eckhard
this question is similar in spirit to this question. I am looking for some guidance in setting up a design matrix for a two-way repeated measures ANOVA with one between-subject factor group (3 levels) and one within-subject factor time (3 levels).
I am assuming data in the order
Subject-1 Group-1 Time-1
Subject-2 Group-1 Time-1
Subject-3 Group-2 Time-1
Subject-4 Group-2 Time-1
Subject-5 Group-3 Time-1
Subject-6 Group-3 Time-1
Subject-1 Group-1 Time-2
Subject-2 Group-1 Time-2
Subject-3 Group-2 Time-2
Subject-4 Group-2 Time-2
Subject-5 Group-3 Time-2
Subject-6 Group-3 Time-2
Subject-1 Group-1 Time-3
Subject-2 Group-1 Time-3
Subject-3 Group-2 Time-3
Subject-4 Group-2 Time-3
Subject-5 Group-3 Time-3
Subject-6 Group-3 Time-3
I understand how to model the subject-specific means as individual random effects, but don't see how to code group, time and the interaction group x time. In the answer to the linked question, the two levels were coded by +1 und -1, (and the interaction by the respective product) but how would this be extended to more than two, e.g. three, levels?
Many thanks,
Eckhard
Sep 17, 2015 12:09 AM | Andrew Zalesky
RE: 2-way rm ANOVA with more than 2 levels
Hi Eckhard,
I suggest that you consider simplifying your design if possible.
However, if this is not possible, here is a design matrix for a 2 time points x 3 groups (with no repeated measures):
1 1 1 0 1 0 (time 1, group A)
1 1 1 0 1 0 (time 1 ,group A)
1 1 0 1 0 1 (time 1, group B)
1 1 0 1 0 1 (time 1, group B)
1 1 0 0 0 0 (time 1, group C)
1 1 0 0 0 0 (time 1, group C)
1 -1 1 0 -1 0 (time 2, group A)
1 -1 1 0 -1 0 (time 2, group A)
1 -1 0 1 0 -1 (time 2, group B)
1 -1 0 1 0 -1 (time 2, group B)
1 -1 0 0 0 0 (time 2, group C)
1 -1 0 0 0 0 time 2, group C)
The 1st column is a constant.
2nd column is the two time points.
3rd is group A minus group C
4th is group B minus group C
5th and 6th column model the group x time interaction
To test for a difference between groups, you would select an F-test and contrast [0 0 1 1 0 0]
To test for a group x time interaction, you would select and F-test and contrast [0 0 0 0 1 1]
If you want to convert this to a repeated measure design, remove the 1st column of ones and replace with new columns to model the mean of each subject (one column per subject). For repeated measures, you will also need to remove column 3 and 4 (main effect of group), since you will most likely only be interested in the group x time interaction.
To extend this to a 3 x 3 design - you will need to add another column for time and another interaction terms. This gives a complicated model.
Perhaps you might want to start with a 2 x 3 design as a first cut.
Andrew
I suggest that you consider simplifying your design if possible.
However, if this is not possible, here is a design matrix for a 2 time points x 3 groups (with no repeated measures):
1 1 1 0 1 0 (time 1, group A)
1 1 1 0 1 0 (time 1 ,group A)
1 1 0 1 0 1 (time 1, group B)
1 1 0 1 0 1 (time 1, group B)
1 1 0 0 0 0 (time 1, group C)
1 1 0 0 0 0 (time 1, group C)
1 -1 1 0 -1 0 (time 2, group A)
1 -1 1 0 -1 0 (time 2, group A)
1 -1 0 1 0 -1 (time 2, group B)
1 -1 0 1 0 -1 (time 2, group B)
1 -1 0 0 0 0 (time 2, group C)
1 -1 0 0 0 0 time 2, group C)
The 1st column is a constant.
2nd column is the two time points.
3rd is group A minus group C
4th is group B minus group C
5th and 6th column model the group x time interaction
To test for a difference between groups, you would select an F-test and contrast [0 0 1 1 0 0]
To test for a group x time interaction, you would select and F-test and contrast [0 0 0 0 1 1]
If you want to convert this to a repeated measure design, remove the 1st column of ones and replace with new columns to model the mean of each subject (one column per subject). For repeated measures, you will also need to remove column 3 and 4 (main effect of group), since you will most likely only be interested in the group x time interaction.
To extend this to a 3 x 3 design - you will need to add another column for time and another interaction terms. This gives a complicated model.
Perhaps you might want to start with a 2 x 3 design as a first cut.
Andrew
