help > RE: design matrix of ANOVA
Nov 17, 2017  12:11 PM | Xiaonan Guo
RE: design matrix of ANOVA
Hi Andrew,
Many thanks for your help. 
Another question about NBSglm: 
design matrix:
1 1 1 1
1 1 1 1
1 -1 -1 1
1 -1 -1 1
-1 1 -1 1
-1 1 -1 1
-1 -1 1 1
-1 -1 1 1
Where the first column is the group, the second column gender, 3rd the interaction effect between group and gender, 4th column is intercept.

y=[1;1;1;1;1;1;1;1];
My F contrasts are [1 0 0 0],[0 1 0 0],[0 0 1 0] for main effects of group and gender and interaction effect, respectively.

After 5000 permutations, all the 5001 Test_Stat all the same, as expected.
However, if number of subjects is different among groups, for example adding a last row to the design matrix, Test_Stat will be different among permutations.
e.g.
design matrix:
1 1 1 1
1 1 1 1
1 -1 -1 1
1 -1 -1 1
-1 1 -1 1
-1 1 -1 1
-1 -1 1 1
-1 -1 1 1
-1 -1 1 1

y=[1;1;1;1;1;1;1;1;1];
After 5000 permutations, we will get different Test_Stat values.
I am quite confused about this result. All responsible variables are the same for subjects, then we should obtain the same vector of y after each permutation. As a result, we should get the same Test_Stat values. But NBSglm result doesn't match our expectation in this case. Why can this happen?
Thanks!


Best wishes,
Xiaonan

Originally posted by Andrew Zalesky:
Hi Xiaonan,

the first formulation (factor effects) is the formulation that is expected by NBSglm.This will work correctly. You can also use a t-test instead of F-test to assess one-sided alternative hypotheses.

I don't think the cell formulation will work correctly.

The column of 1's simply models the global mean. It is not particularly surprising that this column is significant, especially if you do not de-mean your data. This is not a problem. Not sure what you mean by finding a NaN.

Andrew





Originally posted by Xiaonan Guo:
Hi Andrew,
When I perform between-subject two-way ANOVA using NBSglm, I am somewhat confused about the design matrix. I tried two types of design matrix with corresponding contrast matrix, but got different observed test statistics. Here is a short example,
The first one is factor effects approach:
1  1  1  1
1  1  1  1
1  -1  -1  1
1  -1  -1  1
-1  1  -1  1
-1  1  -1  1
-1  -1  1  1
-1  -1  1  1
Where the first column is the group, the second column gender, 3rd the interaction effect between group and gender, 4th column is intercept.
My F contrasts are [1 0 0 0],[0 1 0 0],[0 0 1 0] for main effects of group and gender and interaction effect, respectively.
The second one is cell approach:
1 0 0 0
1 0 0 0
0 1 0 0
0 1 0 0
0 0 1 0
0 0 1 0
0 0 0 1
0 0 0 1
My F contrasts are [1 1 -1 -1], [1 -1 1 -1], [1 -1 -1 1].
Which one is correct for NBSglm?
Another question, in the case of cell approach, all the main effects and interaction effect are the same. It seems that there's somethings wrong with this approach.


Then if I used the factor effects approach, there's another question that confused me. If all the responsible variables are the same for all subjects, for example a column of ones, we will find significant main effect. That's really strange. I also tried glmfit to perform the same procedure, and all the results are NaN. Why does this happen?



Best wishes,
Xiaonan

Threaded View

TitleAuthorDate
Xiaonan Guo Nov 16, 2017
Andrew Zalesky Nov 17, 2017
RE: design matrix of ANOVA
Xiaonan Guo Nov 17, 2017
Andrew Zalesky Nov 17, 2017
Xiaonan Guo Nov 17, 2017