help > 2x3 Mixed Design ANOVA
Showing 1-20 of 20 posts
Display:
Results per page:
Oct 10, 2018  02:10 PM | Ana Coelho
2x3 Mixed Design ANOVA
Hi Dr. Zalesky,

I would like to do a 2x3 mixed ANOVA analysis and I was hoping that you could confirm that my design matrix is correct.
So, I have two groups (good and bad cognitive performers) and they were evaluated at 3 timepoints. I want to evaluate the interaction group x time

My data is organized as follows:
good1-time1
good1-time2
good1-time3
good2-time1
good2-time2
good2-time3
...
bad1-time1
bad1-time2
bad1-time3
bad2-time1
bad2-time2
bad2-time3
...

The design matrix for an example with 4 subjects will be something like this:
1 0 1 0 1 0 0 0
0 1 0 1 1 0 0 0
0 0 0 0 1 0 0 0
1 0 1 0 0 1 0 0
0 1 0 1 0 1 0 0
0 0 0 0 0 1 0 0
1 0 -1 0 0 0 1 0
0 1 0 -1 0 0 1 0
0 0 0 0 0 0 1 0
1 0 -1 0 0 0 0 1
0 1 0 -1 0 0 0 1
0 0 0 0 0 0 0 1

where the first 2 columns model time. columns 3 and 4 model interaction and last 4 columns the subject means. 
Is this design correct? 

Thanks in advance!
Best regards,
Ana
Oct 10, 2018  10:10 PM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

your design matrix appears to be correct. I don't see any errors.

However, in the case of three time points, you may want to test a specific hypothesis such that connectivity strictly increases (or decreases) with time: time1 < time2 < time3. This will afford greater power than testing the general case in which all combinations are possible. While I am not familiar with your application, there may be some sequences (e.g. time2 > time3 > time1) that are not realistic to test and shoud therefore be excluded a priori.

Remember to include exchange blocks, given that your design appears to be repeated measures.

To test the main effect of time, the contrast for an F-test would be: [1 1 0 0 0.....]

Andrew


Originally posted by Ana Coelho:
Hi Dr. Zalesky,

I would like to do a 2x3 mixed ANOVA analysis and I was hoping that you could confirm that my design matrix is correct.
So, I have two groups (good and bad cognitive performers) and they were evaluated at 3 timepoints. I want to evaluate the interaction group x time

My data is organized as follows:
good1-time1
good1-time2
good1-time3
good2-time1
good2-time2
good2-time3
...
bad1-time1
bad1-time2
bad1-time3
bad2-time1
bad2-time2
bad2-time3
...

The design matrix for an example with 4 subjects will be something like this:
1 0 1 0 1 0 0 0
0 1 0 1 1 0 0 0
0 0 0 0 1 0 0 0
1 0 1 0 0 1 0 0
0 1 0 1 0 1 0 0
0 0 0 0 0 1 0 0
1 0 -1 0 0 0 1 0
0 1 0 -1 0 0 1 0
0 0 0 0 0 0 1 0
1 0 -1 0 0 0 0 1
0 1 0 -1 0 0 0 1
0 0 0 0 0 0 0 1

where the first 2 columns model time. columns 3 and 4 model interaction and last 4 columns the subject means. 
Is this design correct? 

Thanks in advance!
Best regards,
Ana
Oct 11, 2018  08:10 AM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Thank you very much for your quick reply.

It's true that I want to test specific hypothesis. This is an aging study and I am using diffusion data to build structural connectivity. So, I want to test if structural connectivity will decrease with time but increases could also happen, so I want to test both hypothesis: time1 > time2 > time3; time1< time2 < time3. How can I do this?
Another thing, the time between acquisitions in the 3 timepoints is not the same for all subjects. From time1 to time2 it varies between 16 to 31 months and from time 2 to time3 between 25 to 55 months. Should I include this in the model as cofounds? If true, how can I do this?


Thanks in advance!
Best regards,
Ana
Oct 12, 2018  01:10 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

A simple design to test the ordering of time1 > time2 > time3 is to use a design matrix with two columns: Column 1 is filled with ones; Column 2 contains a 1 for time point 1, 2 for time point 2 and 3 for time point 3. Additional columns are needed to model the within-subject (repeated measures) effects. These would be the same the previous design. The contrast for a t-test would be [0 1 0 0 0...] and [0 -1 0 0 0...]. The first contrast tests t1 > t2 > t3, while the second contrast tests t1 < t2 < t3.

Note that this is a very simple design and assumes a linear increases (or decrease) over time, as well as other assumptions. There are more advanced models available that you might want to investigate.

If the gap between t1 and t2 is smaller than the gap between t2 and t3, you can put a value higher than 3 in the design matrix for time point 3.

Andrew


Originally posted by Ana Coelho:
Thank you very much for your quick reply.

It's true that I want to test specific hypothesis. This is an aging study and I am using diffusion data to build structural connectivity. So, I want to test if structural connectivity will decrease with time but increases could also happen, so I want to test both hypothesis: time1 > time2 > time3; time1< time2 < time3. How can I do this?
Another thing, the time between acquisitions in the 3 timepoints is not the same for all subjects. From time1 to time2 it varies between 16 to 31 months and from time 2 to time3 between 25 to 55 months. Should I include this in the model as cofounds? If true, how can I do this?


Thanks in advance!
Best regards,
Ana
Oct 12, 2018  01:10 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Once again, thank you for your answer Dr. Zalesky!

Just to clarify some things if I want to evaluate the linear increase: time1 < time2 < time3 and also taking into account that we have 2 groups (good performers vs. poor performers) then my design matrix for an example with 4 subjects will be something like this:

1 1 0 0 0 0 0 1 0 0 0 
1 0 2 0 0 0 0 1 0 0 0
1 0 0 4 0 0 0 1 0 0 0 
1 1 0 0 0 0 0 0 1 0 0
1 0 2 0 0 0 0 0 1 0 0
1 0 0 4 0 0 0 0 1 0 0
1 0 0 0 1 0 0 0 0 1 0
1 0 0 0 0 2 0 0 0 1 0
1 0 0 0 0 0 4 0 0 1 0
1 0 0 0 1 0 0 0 0 0 1
1 0 0 0 0 2 0 0 0 0 1
1 0 0 0 0 0 4 0 0 0 1

where columns 2 to 4 model time for group1 and columns 5 to 7 model time for group2. The last 4 columns model each subject.
The contrast for linear increase in the group 1 will be: [0 -1 0 1 0 ...] Is this contrast correct? Because you mentioned that contrasts will be [0 1 0 0...] for t1 > t2 > t3 and [0 -1 0 0...] for t1 < t2 < t3, but I don't get it how this reflects the linear increase.


Thanks in advance!
Best regards,
Ana
Oct 15, 2018  12:10 PM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

this is not quite what I had in mind. I don't think that your proposed design matrix will work.

I was thinking of the following design matrix:

1 1
1 2
1 4
1 1
1 2
1 4
1 1
1 2
1 4
1 1
1 2
1 4

I have not included the within subjects effects. Need to include another 4 columns to model these effects, as you have done below.

Contrast is [0 1 0 0 0 0] to test for t1 < t2 < t3 and [0 -1 0 0 0 0] to test for t1> t2> t3.

Select "t-test"

The assumption here is that the increase in connectivity between t2 and t3 is exactly twice that of the increase between t1 and t2. Need to assess whether this assumption is realistic.

Note that there are more sophisticated tests to assess parametric increases with time, although they cannot be coded in terms of a GLM.

Andrew


Originally posted by Ana Coelho:
Once again, thank you for your answer Dr. Zalesky!

Just to clarify some things if I want to evaluate the linear increase: time1 < time2 < time3 and also taking into account that we have 2 groups (good performers vs. poor performers) then my design matrix for an example with 4 subjects will be something like this:

1 1 0 0 0 0 0 1 0 0 0 
1 0 2 0 0 0 0 1 0 0 0
1 0 0 4 0 0 0 1 0 0 0 
1 1 0 0 0 0 0 0 1 0 0
1 0 2 0 0 0 0 0 1 0 0
1 0 0 4 0 0 0 0 1 0 0
1 0 0 0 1 0 0 0 0 1 0
1 0 0 0 0 2 0 0 0 1 0
1 0 0 0 0 0 4 0 0 1 0
1 0 0 0 1 0 0 0 0 0 1
1 0 0 0 0 2 0 0 0 0 1
1 0 0 0 0 0 4 0 0 0 1

where columns 2 to 4 model time for group1 and columns 5 to 7 model time for group2. The last 4 columns model each subject.
The contrast for linear increase in the group 1 will be: [0 -1 0 1 0 ...] Is this contrast correct? Because you mentioned that contrasts will be [0 1 0 0...] for t1 > t2 > t3 and [0 -1 0 0...] for t1 < t2 < t3, but I don't get it how this reflects the linear increase.


Thanks in advance!
Best regards,
Ana
Oct 15, 2018  01:10 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Hi Dr. Zaleksy,

I didn't get your first answer right and actually the matrix I proposed was rank deficient. 
The matrix you proposed makes more sense, I already tried it and got some results. 
One last doubt is if I can include the groups (between subjects effect) in this design matrix? 


Thanks in advance!
Best regards,
Ana
Oct 16, 2018  12:10 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

Yes the matrix you proposed will be rank deficient and won't work.

You should be able to add between-group contrast. Just add an extra column in which the two groups are encoded as 0/1 or 0/-1.

Andrew


Originally posted by Ana Coelho:
Hi Dr. Zaleksy,

I didn't get your first answer right and actually the matrix I proposed was rank deficient. 
The matrix you proposed makes more sense, I already tried it and got some results. 
One last doubt is if I can include the groups (between subjects effect) in this design matrix? 


Thanks in advance!
Best regards,
Ana
Oct 18, 2018  01:10 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Hi Dr. Zalesky,

When I add one column with the two groups encoded as 0/1, I got the warning for rank deficiency.
Why this is happening? Is related with the data or the design matrix?


Thanks in advance!
Ana
Oct 19, 2018  01:10 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

I forgot that your design is a repeated measures design. If you are only interested in the group effect, a repeated measures design is not necessary. You can either run a between-group t-test for each time point or first average your data across time points and perform a single t-test of the between-group difference.

What you might be interested in testing for the current repeated measures design is the interaction between group and time. Assuming that the first 8 subjects are group 1 and the last 8 subjects are group 2, the design matrix would look like this:


 1 1
 2 2
 4 4
 1 1
 2 2
 4 4
 1 -1
 2 -2
 4 -4
 1 -1
 2 -2
 4 -4

Once again, you will need to add additional columns (one for each subject) to model within-subject effects.





Originally posted by Ana Coelho:
Hi Dr. Zalesky,

When I add one column with the two groups encoded as 0/1, I got the warning for rank deficiency.
Why this is happening? Is related with the data or the design matrix?


Thanks in advance!
Ana
Oct 19, 2018  08:10 AM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
That was exactly what I needed.
Since I am adding the column for the interaction, should I choose the F-test or t-test?


Thank you very much for your help, Dr. Zalesky!

Best regards,
Ana
Oct 22, 2018  05:10 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
For the design where I add the column for the interaction, should I choose the F-test?


Best regards,
Ana
Oct 22, 2018  11:10 PM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Either a t-test or F-test can be used.

For an F-test, the contrast should contain a 1 for the interaction column and zeros elsewhere.

For a t-test, the contrast should contain a 1 or -1 for the interaction column and zeros elsewhere.

A t-test will allow you to test for positive and negative interactions separately.

F-test is sensitive to any kind of interaction (positive or negative).


Originally posted by Ana Coelho:
For the design where I add the column for the interaction, should I choose the F-test?


Best regards,
Ana
Oct 25, 2018  12:10 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
If I use a t-test for the interaction how can I calculate the degrees of freedom?
Is it just: number of subjects - 1 ?


Thanks!
Best regards,
Ana
Oct 26, 2018  06:10 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

the degrees of freedom are computed internally. You should never need to specify them. Roughly speaking, dof is given by number of samples minus number of predictors, but this will vary according to the test.
Andrew


Originally posted by Ana Coelho:
If I use a t-test for the interaction how can I calculate the degrees of freedom?
Is it just: number of subjects - 1 ?


Thanks!
Best regards,
Ana
Oct 26, 2018  08:10 AM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Hi Andrew,

I was asking because I need the degrees of freedom to calculate the threshold (t value) to use in NBS. Is this correct?


Thanks!
Best regards,
Ana
Oct 27, 2018  12:10 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
For a two-sample t-test, the degrees of freedom is number of samples/observation minus 2 (assuming no other covariates).


Originally posted by Ana Coelho:
Hi Andrew,

I was asking because I need the degrees of freedom to calculate the threshold (t value) to use in NBS. Is this correct?


Thanks!
Best regards,
Ana
Mar 12, 2019  10:03 AM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Hi Dr. Zalesky,

In this repeated measures design (3 timepoints and 2 groups) is it possible to include covariates?


Thanks in advance!
Ana 

Originally posted by Andrew Zalesky:
Hi Ana,

I forgot that your design is a repeated measures design. If you are only interested in the group effect, a repeated measures design is not necessary. You can either run a between-group t-test for each time point or first average your data across time points and perform a single t-test of the between-group difference.

What you might be interested in testing for the current repeated measures design is the interaction between group and time. Assuming that the first 8 subjects are group 1 and the last 8 subjects are group 2, the design matrix would look like this:


 1 1
 2 2
 4 4
 1 1
 2 2
 4 4
 1 -1
 2 -2
 4 -4
 1 -1
 2 -2
 4 -4

Once again, you will need to add additional columns (one for each subject) to model within-subject effects.




Mar 13, 2019  10:03 AM | Andrew Zalesky
RE: 2x3 Mixed Design ANOVA
Hi Ana,

To add a covariate, simply add an additional column to your design matrix that contains that covariate.

Then add a zero to your contrast vector to indicate that it is a covariate of no interest.

Andrew


Originally posted by Ana Coelho:
Hi Dr. Zalesky,

In this repeated measures design (3 timepoints and 2 groups) is it possible to include covariates?


Thanks in advance!
Ana 

Originally posted by Andrew Zalesky:
Hi Ana,

I forgot that your design is a repeated measures design. If you are only interested in the group effect, a repeated measures design is not necessary. You can either run a between-group t-test for each time point or first average your data across time points and perform a single t-test of the between-group difference.

What you might be interested in testing for the current repeated measures design is the interaction between group and time. Assuming that the first 8 subjects are group 1 and the last 8 subjects are group 2, the design matrix would look like this:


 1 1
 2 2
 4 4
 1 1
 2 2
 4 4
 1 -1
 2 -2
 4 -4
 1 -1
 2 -2
 4 -4

Once again, you will need to add additional columns (one for each subject) to model within-subject effects.




Mar 13, 2019  04:03 PM | Ana Coelho
RE: 2x3 Mixed Design ANOVA
Thank you for your help!


Best regards,
Ana