I have data with two between-subjects variables. Since this data is unbalanced, I am trying to use the linear mixed-effects modeling to see if the interaction between the variables is a significant predictor of DV. But I am not sure if I modeled the data correctly, and I was wondering if I could get some help here since I am a beginner in mixed linear modeling.

To explain more about my data, the between-subjects variables (fixed effects) are:

  1. Curriculum (Curriculum A, Curriculum B), and the
  2. Class mode (In-person, Online). So, there could be four groups (Curriculum A & In-person, Curriculum A & Online, Curriculum B & In-person, Curriculum B & Online) to which each participant could be assigned. Each participant was assigned to only one of these groups.

I would like to know if there was a significant interaction effect between Curriculum and Class mode on the Test Score (DV). I am using Matlab’s fitlme function, but I am aware that the syntax for the mixed effect model function is pretty similar in R. My initial thought was that I can model the data like the following (Result1). By the way, ‘LME2’ is a matrix that contains the data, the ‘subjectID2’ column contains the participant number, and (1|subjectID2) is a way of specifying the random intercept for 'subjectID2' in Matlab.

Result1=fitlme(LME2, 'testScore ~ curriculum * classMode + (1|subjectID2)', 'FitMethod', 'REML');

However, it came to my thought that I should be controlling for the random intercept arising from the fixed effects ‘curriculum’ and ‘classMediam’, so I revised the line as follows:

Result2=fitlme(LME2, 'testScore ~ curriculum * classMode + (1|subjectID2) + (1|curriculum) + (1|classMode)', 'FitMethod', 'REML');

My specific questions are:

  1. Based on the design of the study, which is the correct way of modeling the data? Result1 or as Result2?
  2. If the ‘Result2’ model is correct, should I remove the intercept term for subjectID2 (1|subjectID2)? I feel like since I am controlling for the random intercepts of the groups ‘curriculum’ and ‘classMediam’, it may be unnecessary to control for the random intercept for the subject, but this is just a guess.
  3. If you use Matlab to fit LME models, is there a way of specifying the AR2 matrix as the covariance matrix? It seems that Matlab only has Cholesky, Diagonal, Isotropic, and Compound Symmetry matrices as options.

Thank you in advance!

Hansol R.

  • $\begingroup$ Can you clarify how many testScore values you have per subject? If you have multiple testScore values per sibject, can you clarify at what time points these are collected? Are these time points the same for all subjects? $\endgroup$ Feb 7, 2021 at 21:41

1 Answer 1


You have repeated measures within subjects so (1|subjectID2) is appropriate.

curriculum and classMode are your fixed effects and the focus of your research question, so these should not be grouping variabls for random itercepts.

The first model is the better one.

Questions about how to do things in specific software are off-topic here, and I don't know MATLAB in any case, so can't help with the AR2 matrix.

  • $\begingroup$ Hi Robert, Thank you so much for your response. It helped me get a better understanding of how I should model the data. Again, thank you so much! $\endgroup$ Feb 7, 2021 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.