Mixed-effects model in R

Discuss statistics related things
Post Reply
djkembrey
Posts: 9
Joined: Mon Jun 06, 2022 5:03 pm

Mixed-effects model in R

Post by djkembrey »

Hi,

I am trying to run a power analysis in R (using mixedpower) for a mixed-effects model that I ran I initially ran in Jamovi. However, the output in R is different from what I got in Jamovi.

It is a model with one categorical predictor, one continuous predictor, and two random intercepts. I have defined the categorical predictor as a factor using mydata$v1 <- factor(mydata$v1,levels = c(1,2),
labels = c("past", "future")) and applied contrast coding using contrasts(mydata$v1).

Is there something I am missing? I am fairly new to R so any suggestions would be helpful.
User avatar
mcfanda@gmail.com
Posts: 457
Joined: Thu Mar 23, 2017 9:24 pm

Re: Mixed-effects model in R

Post by mcfanda@gmail.com »

First, the continuous independent variables in jamovi are centered on their means (which is recommended for convergence). Second, it is not clear how you set the contrast coding (which is a general term for giving coding to a categorical variable). What was your X() in the R line "contrasts(mydata$v1)<-X()"?
djkembrey
Posts: 9
Joined: Mon Jun 06, 2022 5:03 pm

Re: Mixed-effects model in R

Post by djkembrey »

Thanks for your reply. I thought it might be due to centering - how can I mean center the variables in R?

In terms of contrast coding, I haven't got the "<-X()" part of the code and I'm not entirely sure what this needs to be. Any help would be very much appreciated. Please let me know if you need more information about the dataset.
djkembrey
Posts: 9
Joined: Mon Jun 06, 2022 5:03 pm

Re: Mixed-effects model in R

Post by djkembrey »

I have now centered my continuous predictor using myvariable = scale(mydata$myvariable, center=TRUE, scale=TRUE) and set the contrast coding of my categorical predictor using (contrasts(mydata$myvariable)<- c(-0.5, +0.5)) and I am still getting different results in R versus Jamovi. I checked the contrast coefficients in Jamovi and the two levels of my categorical predictor are -0.5 and 0.5, which is what I have now set it to in R. However, there is no change to the original result.
djkembrey
Posts: 9
Joined: Mon Jun 06, 2022 5:03 pm

Re: Mixed-effects model in R

Post by djkembrey »

It also seems that only the output for the categorical predictor is different in jamovi vs R - the output for the continuous predictor and their interaction are the same. Any help on what is causing this would be appreciated but also any insight on whether this will affect the power analysis using mixedpower would be great.
Post Reply