help > RE: Design matrix and contrast for 2 way ANOVA, and f-value
May 31, 2019  07:05 PM | Andrew Zalesky
RE: Design matrix and contrast for 2 way ANOVA, and f-value
Hi Woomi,

You will most likely need to add a column of 1's to your design matrix to model the global mean, unless all of your data has been globally de-meaned.

The two ways that you could model this design are as follows:

1  1 -1 -1
1 -1  1 -1
1 -1 -1  1
1  1  1   1

OR:

1 1 0 0
1 0 1 0
1 0 0 0
1 1 1 1

Your design matrix is also correct (except that you need to include a column of 1's). All these design matrices will yield the same result for the interaction effect. However, the two main effects will differ between the two designs - this is because the interpretation of the main effects depends on how the interaction effect is modeled. This is a general property of the general linear model, and not unique to the NBS.

The contrasts that you have are correct.

I would probably use a t-test and independently test the two contrast of [0 0 0 1] and [0 0 0 -1]. But it is also fine to use a f-test and thus only consider [0 0 0 1], which will essentially yield a two-sided p-value, whereas as using a t-test will return a one-sided p-value.

You should not need to compute any f-value yourself. The f statistic is computed internally as part of the software.

Andrew

Originally posted by Woomi Ban:
Hi Dr.Zalesky,

Thank you for your efforts in creating this wonderful tool.
It's super easy and intuitive, and I can understand how to use this tool through the forum.
But still, I'm not sure my design matrix and contrast are correct.

I'd like to do 2x2 ANOVA analysis using NBS.
I have 4 groups(A,B,C,and D) and 41 subjects in total. Each group has sex and exposure differences as follows:

A: Female, Water (Number of Subjects: 12)
B: Male, Drug (Number of Subjects: 9)
C: Male, Water (Number of Subjects: 10)
D: Female, Drug (Number of Subjects: 10)

So I will use design matrix as follow:

1 -1 0 (for Group A)
-1 1 0 (for Group B)
-1 -1 0 (for Group C)
1 1 1 (for Group D)

The first column represents female(1) and male(-1).
The seconde column represents water(1) and drug(-1).
The third column represents the interaction of female and drug.

I'm interest in main effects of sex and exposure, and the interaction of sex and exposure.
So I will try below contrast:
1) main effect of sex: [1 0 0]
2) main effect of exposure: [0 1 0]
3) interaction of sex and exposure: [0 0 1]

I wonder if above design matrix and contrast are correct.
Especially, I wonder if the third contrast will show the sex x exposure interaction correctly.

Also, I think I need to select f-test for this analysis, but I'm confusing how can I calculate the f-value in this case.
Can I use (number of group - 1) for numerator and (number of subjects - number of group) for denominator?
So in this study numerator would be 3 and denominator would be 37. Is this correct?

Thank you so much!!
Woomi

TitleAuthorDate
Woomi Ban May 30, 2019
davideit7 Dec 5, 2019
Andrew Zalesky Dec 5, 2019
davideit7 Dec 6, 2019
Andrew Zalesky Dec 6, 2019
davideit7 Jan 20, 2020
Andrew Zalesky Jan 21, 2020
davideit7 Jan 22, 2020
Andrew Zalesky Jan 22, 2020
Woomi Ban Jun 9, 2019
Andrew Zalesky Jun 9, 2019
RE: Design matrix and contrast for 2 way ANOVA, and f-value
Andrew Zalesky May 31, 2019