Defining a formula for a linear mixed effects model
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Kartik Saxena
el 8 de En. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Linear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!