Using Linear Mixed Models with two fixed factors and a random factor
7 ビュー (過去 30 日間)
古いコメントを表示
I am trying to make a Linear Mixed Model to see if there is a statistical significance with two fixed factors ('ANTS and LABEL') with the ('STATE') as a random factor. Can anyone suggest to me how to proceed with such a model in Matlab?
Data file is attached alongside a sample code. Is the code right?
m = fitlme(data, 'RATE ~ (ANT*LABEL) + (1 | STATE)');
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower Upper
{'(Intercept)' } 0.033027 0.0056879 5.8065 294 1.6533e-08 0.021832 0.044221
{'ANTS' } -0.00012262 0.00065256 -0.1879 294 0.85108 -0.0014069 0.0011617
{'LABEL_Poor nest' } -0.015508 0.0080189 -1.934 294 0.054076 -0.03129 0.00027342
{'ANTS:LABEL_Poor nest'} 0.00036122 0.0009203 0.3925 294 0.69497 -0.00145 0.0021724
0 件のコメント
採用された回答
the cyclist
2021 年 10 月 11 日
編集済み: the cyclist
2021 年 10 月 11 日
You can fit such a model using the fitlme function from the Statistics and Machine Learning Toolbox.
I think the following code fits the model you mentioned:
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/764231/Entry_rates.xlsx'); % You can just read in your local file
mdl = fitlme(data,'RATE ~ ANTS + LABEL + (1|STATE)')
But I strongly recommend you read the documentation carefully, to understand how to specify the model you want to fit.
6 件のコメント
the cyclist
2021 年 10 月 11 日
The first model I suggested treats ANTS as continuous numeric by default, so we need to convert it to categorical before putting it in the model.
This model has the interaction term as well:
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/764231/Entry_rates.xlsx'); % You can just read in your local file
data.ANTS = categorical(data.ANTS);
m = fitlme(data, 'RATE ~ (ANTS*LABEL) + (1 | STATE)')
Does that align better with the output you would expect, and can interpret?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!