Hello LM_BU
From what I gather, you are working with generalised linear mixed-effects model and you are performing hypothesis testing for the model that has a 3 way interaction between variables that have 2 levels each. You want to understand how to set up contrast vectors for your hypothesis.
Given that you are using effects coding, the main effects of the different variables will be coded as [1 -1]. To set up contrasts for a particular hypothesis, we need to consider only the interactions that focus on the coefficients with the variables that we need. You can find the method to set up contrasts for the two hypotheses mentioned by you below.
Hypothesis 1: Rotated versus Straight for Males and Usability_B:
- We’ll only consider the effects of the the variable “Type” with the “Male” and “Usability_B” levels. Thus, the contrast set up by you for the case is accurate.
Hypothesis 2: Female versus Male (regardless of Usability and Type)
- Initialize the contrast vector with zeros. The length of the vector should match the number of fixed effects coefficients in the model, which is 7.
- Set the value for the "Gender" coefficient in the contrast vector.
- The "Gender" coefficient is in the 3rd position of the fixed effects.
- The value for the "Gender" coefficient in the contrast vector is "8", which is the sum of the "Gender" coefficients for "Female" (1+1+1+1) minus the sum for "Male" (-1-1-1-1).
- We do not need to divide by the number of combinations (4) because "coefTest" will handle the scaling appropriately.
- The interaction terms involving "Gender" ("Usability:Gender", "Type:Gender", "Usability:Type:Gender") will sum to zero and are not included in the contrast vector for this main effect test.
- The resulting contrast vector will have the value "8" in the 3rd position and "0" in all other positions.
L_gender = zeros(1, 7);
L_gender(3) = 1+1+1+1 - (-1-1-1-1);
For further understanding on the methods mentioned above, you can refer to the following MATLAB Documentation:
- “GeneralizedLinearMixedModel” class: https://www.mathworks.com/help/stats/generalizedlinearmixedmodel-class.html
- “coefTest” function. Navigate to the “Input Arguments” section to read about fixed-effects contrasts: https://www.mathworks.com/help/stats/generalizedlinearmixedmodel.coeftest.html
I hope you find the above explanation and suggestions useful!