Page 1 of 1

Contrasts - Repeated - Contrast coefficient table

Posted: Mon Jul 17, 2023 1:31 am
by Doppler44
ImageGood evening,

I am a new user and like your program (thank you!); I'll put my question to the top and then try to explain as well as I can.
Is it possible that some of the contrasts in the linear mixed model operations correctly calculate the Fixed Effect Parameter estimates but display incorrect contrast coefficients?

I found some older posts with concerns about contrasts and their coding but I didn't see "REPEATED" discussed and wondered if possibly the same issue was occurring. I have spent some time trying to find an answer and do appreciate that some programs and sites use different terminology for these predesigned contrasts.

Details: I am confused about the contrast coefficient table in my output when performing a mixed model operation and requesting "Repeated" for the factor coding and contrasts. I thought that this contrast matrix compares the means of each successive categorical variable (mine is "Time" with five ordered levels). My dependent variable is respiratory rate (RR).
In other words I want to compare the means of: Time 1(baseline) - Time 2; Time 2 - Time 3; Time 3 - Time 4; Time 4 - Time 5.
I have a biologic reason for wanting these comparisons (we know from literature that the successive values of this DV decrease with most therapies). The model was run with one random variable (subject ID, intercept; n=23)

I think the fixed parameter estimates are actually CORRECT because these are the same values that return from JASP when I create a "customized" set of contrasts that I would interpret as coding for "repeated". I used the same coding in JASP as I would use in SPSS for operator selected (custom) contrasts, that is shown below (from SPSS in which Time is shown in the rows and contrasts in the columns)

Contrast Coefficients (L' Matrix)
Parameter Measurement Period Repeated Contrast
Level 1 vs. Level 2 Level 2 vs. Level 3 Level 3 vs. Level 4 Level 4 vs. Level 5
Intercept 0 0 0 0
[Time=1] 1 0 0 0
[Time=2] -1 1 0 0
[Time=3] 0 -1 1 0
[Time=4] 0 0 -1 1
[Time=5] 0 0 0 -1
The default display of this matrix is the transpose of the corresponding L matrix.

I entered my contrasts this way in JASP (using custom contrasts):
contrast
1 2 3 4
Time 1 -1 0 0 0
2 1 1 0 0
3 0 -1 1 0
4 0 0 -1 1
5 0 0 0 -1

THE FOLLOWING is the the contrast coefficients coding in jamovi using the "repeated" command. It seems to me that the program is comparing the mean of Time 1 to the mean of the following four times (not only the mean of Time 2); then the the mean of combined Times 1 and 2 to the means of times (3,4,5); then the mean of times (1,2,3) to the next two times, etc.

Contrast Time
1 2 3 4 5
1-2 0.8 -0.2 -0.2 -0.2 -0.2
2-3 0.6 0.6 -0.4 -0.4 -0.4
3-4 0.4 0.4 0.4 -0.6 -0.6
4-5 0.2 0.2 0.2 0.2 -0.8
5-6 0.8 -0.2 0.2 0.2 -0.2

I have attached the partial outputs from jamovi and from JASP to this message (one jpeg image)
Regardless of what we call this contrast, is it possible this coding immediately above is not correct but the calculations are correct, or do I simply not understand the repeat coding method (or perhaps contrast coding at all for that matter :)

Thanks very much for any feedback or instructions you might advance.

Re: Contrasts - Repeated - Contrast coefficient table

Posted: Mon Jul 17, 2023 1:39 am
by Doppler44
Coding Repeated in jamovi.JPG
Coding Repeated in jamovi.JPG (136.15 KiB) Viewed 6885 times

Re: Contrasts - Repeated - Contrast coefficient table

Posted: Tue Sep 12, 2023 10:18 pm
by mcfanda@gmail.com
Hi
I do confirm that the repeated contrast does compare 1-2, 2-3, 3-4 and so on. That is why you get the same estimates across different software. The difference between GAMLj in jamovi and other software is that in GAMLj the repeated contrasts are defined not only to compare the subsequent means as you expect, but also to be centered to the sample mean. Centered contrasts guarantee a much higher chance of convergence of the model, and they well behave when interactions are in the model. The way jamovi defines contrasts assures that the main effects are actually "average effects", as any user of ANOVA would expect. Thus, estimates are the same in jamovi and other software because the contrasts compare the same means. If you include interactions, they main effects will diverge (and jamovi's are the ones you expect, marginal effects)

On a more technical side, what jamovi uses is the generalized inverse of the contrasts you defined in your custom contrasts. In fact, given a contrasts like this (contrasts are column-wise)

Code: Select all

   [,1] [,2] [,3] [,4]
[1,]    1    0    0    0
[2,]   -1    1    0    0
[3,]    0   -1    1    0
[4,]    0    0   -1    1
[5,]    0    0    0   -1
the generalized inverse is (contrasts are row-wise)

Code: Select all

 [,1] [,2] [,3] [,4] [,5]
[1,]  0.8 -0.2 -0.2 -0.2 -0.2
[2,]  0.6  0.6 -0.4 -0.4 -0.4
[3,]  0.4  0.4  0.4 -0.6 -0.6
[4,]  0.2  0.2  0.2  0.2 -0.8
Thus, it is the same contrast but centered to the grand mean.

Re: Contrasts - Repeated - Contrast coefficient table

Posted: Wed Sep 13, 2023 6:31 am
by Doppler44
Thank you for the great explanation