Defining a formula for a linear mixed effects model
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying to run a linear-mixed effects model as part of a mediation analysis. I have the following variables:
x = the predictor
M = the hypothesized mediator;
y = the response variable;
For each of these, i have 5000 observations. These observation were taken from 50 participants, each of them participated in the experiment in one (and only one) of two days. Therefore, i want to use two additional grouping variables:
g1 = subject iD
g2 = day of participation.
Now, I have all the data arranged in a table to insert to "fitlme".
I have managed to produce a formula for 1 grouping variable, as follows:
'y~ x + M + (1 + M | g1)'
Is it correct?
Now I am having troubles defining the formula for the two grouping variables, didn't managed to understand from the documentation.
Would appriciate help with defining the formula, if possible with the logic behind it so I could conclude for next time.
Thanks in advance.
0 个评论
回答(1 个)
Kartik Saxena
2024-1-8
Hi,
I understand that you want to run a linear-mixed effects model with two additional grouping variables.
You can refer to the following example from MathWorks documentation for this purpose:
I hope this resolves your issue.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!