## Mixed model for repeated design

Discuss statistics related things

## Mixed model for repeated design

I tried to replicate an analysis done in R (with lmer) on a design with a within factor (time, 3 measures, ordered factor) and a between factor (group, 3 groups) in Jamov (mixed model).

All the results are the same, except for the contrasts of the variable time (contrast polynomial): the linear constrast is significant in R but not the quadratic contrast
the quadratic contrast is significant in Jamovi, but not the linear constrat

How is it possible? Any suggestions will be welcomed.
fabstat

Posts: 2
Joined: Fri Feb 01, 2019 7:49 am

## Re: Mixed model for repeated design

Hi, can you share the .omv file and the .R file so I can replicate the example? mcfanda@gmail.com

Posts: 217
Joined: Thu Mar 23, 2017 9:24 pm

## Re: Mixed model for repeated design

Hi.
The differences in contrast analysis between R and jamovi gamlj are due to the way categorical variables are coded. Please keep in mind that when you have interactions in a linear model, the linear effect of each variable is computed for the other variable equal to zero. Recall also that in R, if a character variable is not coded by the user, using `contrasts()` or similar functions, it gets coded automatically by lmer() using the function `factor()`.
Now, you have two categorical variables, one coded by you with the function `ordered()` and the other as character variable. When you use it in lmer(), it gets factored automatically and thus the resulting contrast codes are

Code: Select all
`x<-factor(Groupe)contrasts(x)`

C E
A 0 0
C 1 0
E 0 1

This means that the linear and quadratic effects of the variable`visite` are computed for the group Groupe=A. If you want to obtain the same results in jamovi, you should set the factor coding to "dummy" in gamlj.

Let's see now what are the results you obtained in jamovi. Gamlj produces the "main effects", meaning that the linear and quadratic effects are estimated "on average". This is because you set the coding of "Groupe" to "simple". Simple is a very smart contrast coding: it compares the reference group to each of the other groups, but it centers the contrast to 0 (the average of the sample), thus the other variables effects are computed on average. The coding scheme
2 3
A -0.3333333 -0.3333333
C 0.6666667 -0.3333333
E -0.3333333 0.6666667

and can be obtained in R with
Code: Select all
`k<-3 #number of levelscontrasts(x)<-contr.treatment(k)-(1/k)`

If you try in R to code `Groupie` like that, you get the same results as in jamovi. More on contrasts here https://mcfanda.github.io/gamlj_docs/rosetta_contrasts.html mcfanda@gmail.com

Posts: 217
Joined: Thu Mar 23, 2017 9:24 pm