Contrasts - Repeated - Contrast coefficient table

Discuss the jamovi platform, possible improvements, etc.
Post Reply
Doppler44
Posts: 4
Joined: Mon Jul 17, 2023 12:00 am

Contrasts - Repeated - Contrast coefficient table

Post 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.
Doppler44
Posts: 4
Joined: Mon Jul 17, 2023 12:00 am

Re: Contrasts - Repeated - Contrast coefficient table

Post by Doppler44 »

Coding Repeated in jamovi.JPG
Coding Repeated in jamovi.JPG (136.15 KiB) Viewed 6592 times
User avatar
mcfanda@gmail.com
Posts: 462
Joined: Thu Mar 23, 2017 9:24 pm

Re: Contrasts - Repeated - Contrast coefficient table

Post 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.
Doppler44
Posts: 4
Joined: Mon Jul 17, 2023 12:00 am

Re: Contrasts - Repeated - Contrast coefficient table

Post by Doppler44 »

Thank you for the great explanation
Post Reply