Contents
How to create a contrast matrix for LME?
If you want to manually create an appropriate contrast matrix based on specific tests, you can use the ginv function from the MASS package: The resulting matrix allows the tests you are looking for, i.e., level 2 against level 1 and level 3 against level 1.
How is the contrast coding used in regression?
The contrast coding, see below, is more straightforward. It also follows the rule that for effect coding that the values in each new variable sum to zero. The first contrast compares group 1 to group 4, and group 1 is coded “1” and group 4 is coded “-1”.
What are the results of the second contrast?
The results of the second contrast, comparing the mean of write for levels 1 and 3. The expected difference in variable write between group 1 and 3 is 1.7417 and is not statistically significant (t = 0.6374, p = .5246), while the third contrast is statistically significant.
How to create a contrast matrix for a categorical variable?
Let’s create the contrast matrix manually using the scheme shown above. Essentially, the difference between the dummy coding scheme and the simple coding scheme is a constant matrix whose each element is 1/k if our categorical variable has k levels.
How to specify contrasts for a factor with 3 levels?
For a factor with 3 levels, you obtain 2 contrasts. Your interpretation of the contrasts is not correct. The first one tests the first level of the factor against levels 2 and 3. The second contrasts tests the second levels against levels 1 and 3. You manually specified a contrast matrix with cbind (c (-1,1,0), c (-1,0,1)):
What does specifying sum and Contr mean in LME?
If I understand correctly, -1 is the reference level and 1 is the level compared to it. Specifying contr.sum only results in contrasts for the first two columns being given, however.
Which is part of the LME model do you use?
I’m using lme. The fixed-effects part of the model is the interaction between participant group (“play”) and stimuli (“ins”), and the random-effects part is subject grouped within stimulus category. I’m using sum contrasts and would like to see comparisons between each level of the “play” and “ins” variables.