How can I obtain the variability of different values of a categorical variable by separating into strata?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am replicating the results of a study using the following linear mixed-effects model:

The code is:
lme = fitlme(Tabla_datos, 'logxi ~ logH + Material + Material:logH + (1|key)', ...
'FitMethod', 'REML');
With this code, I was able to obtain the data for all fixed effects in the following table (highlighted in blue).

However, I still haven’t been able to achieve the results for variability by material (values highlighted in yellow in the table). I understand that MATLAB assumes a common sigma for all random effects, which is why I want to calculate this variability for the different categories (in this case: materials), treating each material as an independent stratum with its own variability.
Thank you in advance for your responses.
0 commentaires
Réponses (1)
Deep
le 24 Déc 2024
I believe your equation is missing the category variable "Material" as a random effect, adding which will allow you to capture variability specific to each material category. You can modify your model formula to include "Material" as a random effect like this:
lme = fitlme(Tabla_datos, 'logxi ~ logH + Material + Material:logH + (1|key) + (1|Material)', 'FitMethod', 'REML');
You can then use the "randomEffects" function to extract the random effects estimates from the linear mixed-effects model. The following code snippet helps filter and display the statistics related to each "Material" category, while filtering out the other random effects in your equation:
% Extract random effects from the linear mixed-effects model
[~, ~, stats] = randomEffects(lme);
% Filter the statistics only for the group "Material"
isMaterialStats = strcmp(stats.Group, 'Material');
materialStats = stats(isMaterialStats, :);
% Display the results
disp(materialStats);
For further details on the "randomEffects" function, you can refer to the documentation at https://www.mathworks.com/help/stats/linearmixedmodel.randomeffects.html.
0 commentaires
Voir également
Catégories
En savoir plus sur Hypothesis Tests dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!