Define a Linear Mixed-Effects Model with fitlme for a random effects model with a one fixed effect and one random intercept

9 次查看(过去 30 天)
I am trying to determine how to define the formula for the "fitlme" function, which will then be passed into the "randomEffects" function. I have read through the documentation for the "fitlme" function and the documentation on the webpage "Prepare Data for Linear Mixed-Effects Models." However, I am still unsure how to proceed.
Background:
Our laboratory performed volumetric optical imaging on 15 brain tissue samples (five samples were from disease A, five were from disease B, and five were from healthy controls). For each tissue sample, we virtually divided the volumetric optical images into uniform cubic sub samples. For each sub-sample, we calculated a single value for a particular vascular metric. This resulted in a vector of continuous values for each tissue sample.
Goal:
Now, I want to compare the vascular metrics between each disease group and the control group (i.e. disease A vs. control and disease B vs. control). My goal is to determine whether the vascular metric changes signficantly between the disease groups and the control group. I contacted a statistician, who recommended using a random effects model. They recommended defining the following:
  • response = array of values for the vascular metric
  • fixed effect = group (disease A, disease B, or control)
  • random effect = subject identifier
I am now trying to determine how to implement this in Matlab via the "fitlme" function.
Using the "fitlme" function:
Defining the table:
I created two separate tables, one for comparing disease A vs. the control group and a second for comparing disease B vs. the control group. The first column of the tables represents the group identifier (disease_A, disease_B, or control). The second column is the subject identifier (1-15). The third column is a concatenated vector of all of the subsamples across all of the subjects in the respective groups.
Defining the formula:
I am unsure how to define the formula that defines the linear mixed effects model. I would like to set the vector of subsamples as the response variable (y), the vector of groups as the fixed effect, and the subject identifier as the random effect. From reading the documentatoin, I believe this would correspond to the following:
fml = 'subsamples ~ subID + (subID|groups)';
I implemented this and then ran the following code to obtain the estimates of random effects and related statistics:
lme = fitlme(tbl,fml);
[B, Bnames, stats] = randomEffects(lme);
The code ran successfully, and now I am trying to determine whether I correctly initialized the formula. The contents of the "stats" struct for comparing one of the disease groups to control are shown below. The group labels are "AD" and "HC". The value 'subID' refers to the subject ID.
Questions:
  1. Am I correctly defining the formula (fml) for fitting the LME model? I am also open to using the "fitlmematrix" if that is more straightforward. I also attempted to use "fitlmematrix," but I got even more confused on how to define the respective matrices, so I figured I would not include details in this post.
  2. If the p-value (from the "stats" object) is less than my alpha, does this signify that the random effect (subject) does not significantly affect the response (vascular metrics)?
  3. How do I test whether the fixed effect (group) has a significant affect on the response? Would this require defining a different formula for the fitlme function?

回答(1 个)

Garmit Pant
Garmit Pant 2024-7-5
Hello Mackenzie
From what I gather, you are trying to use the ‘fitlme’ function to create a fixed linear mixed effects model and need assistance in setting the formula for the model correctly and then interpreting how different effect groups are affecting the response.
As per your description, the 3 components of your formula are:
  • Response Variable: Vascular metric values (‘subsamples’).
  • Fixed Effect: Group (groups).
  • Random Effect: Subject identifier (‘subID’).
Thus, the formula should be defined as follows:
fml = 'subsamples ~ groups + (1|subID)';
Explanation
  • subsamples: The response variable (vascular metric values).
  • groups: The fixed effect (disease A, disease B, or control).
  • (1|subID): The random intercept for each subject. This specifies that each subject has its own intercept, but the slope for the fixed effect (group) is the same across subjects.
To identify the significance of the random effects, you can inspect the random effects covariance parameters. You can access these using the following code snippet:
disp(lme)
For fixed effects, you need to perform ANOVA testing. That can be done using the following code snippet:
anovaResults = anova(lme);
disp(anovaResults)
The anova results will provide p-values for the fixed effect which can be used to understand their significance on the response.
I hope you find the above explanation and suggestions useful!

类别

Help CenterFile Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by