Defining a formula for a linear mixed effects model

2 visualizaciones (últimos 30 días)
Lior Kritzman
Lior Kritzman el 18 de Mayo de 2022
Respondida: Kartik Saxena el 8 de En. de 2024
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.

Respuestas (1)

Kartik Saxena
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.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by