MATLAB Answers

Implementing Moderation analysis using fitrm when i have a 2 within subjects factors

39 views (last 30 days)
Ketan Jaltare
Ketan Jaltare on 9 Dec 2020
Answered: Aditya Patil on 24 Dec 2020
I have a (A)2x(B)2 within subjects design and a continuous moderator variable (X). I want to test whether X moderates the relationship between A and B. How can I impliment this in matlab using the fitrm function?
I have tried the following :
rm = fitrm(Datamatrix,'A-B ~1 + X','WithinDesign',within);
However I am not sure if this is the right thing to do.
Should i be using the fitlm function instead? If so, can someone explain how i should construct my design matrix for it?
Thanks in advance!

Answers (1)

Aditya Patil
Aditya Patil on 24 Dec 2020
The idea behind repeated measures is that we measure the response variable over time or under different conditions.
  • If A and B are somehow the same, for example measurements of the same variable or of comparable variables with the same units, then you may choose to conduct a repeated measures analysis. For example, you may do the analysis on left arm and right arm of subjects.
  • If A and B are fundamentally different things, then you may choose not to use repeated measures analysis. For example, If A were age and B were weight of some subjects, and they are of very different scales, then you may decide fitrm is not appropriate.
As a workaround, it would be possible to model A and B separately. An advantage is that they would not be constrained to have the same functional relationship. For example, A could be a linear function of X and B could be a quadratic function of X. It would also be possible to study the residuals from the two models in order to decide the degree of correlation between A and B after adjusting for the between-subject models.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!