¿Cómo obtener/considerar la variabilidad para distintas variables categóricas en un modelo lineal de efectos mixtos?

42 Ansichten (letzte 30 Tage)
Buenas, me encuentro realizando un modelo lineal de efectos mixtos de un conjunto de datos en donde tengo como efecto aleatorio un edificio, el cual se tienen distintos datos para un mismo edificio, cómo la altura, periodo, amortiguamiento, etc. Uno de ellos es el material del edificio considerada como variable categórica. Realicé el siguiente código:
lme = fitlme(Tabla_datos, 'logxi ~ logH * Material + (1|key) + (1|key:Material)', ...
'FitMethod', 'REML', ...
'CovariancePattern', {'Full', 'Diagonal'})
Donde key corresponde al nombre del edificio, este código me entrega los parámetros de covarianzas para el edificio, pero lo que yo necesito saber es cómo obtener la variabilidad para cada material en donde se trate a cada material como un estrato independiente con su propia variabilidad

Antworten (1)

Umar
Umar am 31 Okt. 2024 um 2:18

Hi @Sofía Mendoza,

Sorry, I had to use Google translate to provide response to your comments. Instead of modeling the interaction between the building key and material as a single random effect, you can create separate random effects for each material. This would allow you to capture the variability in responses attributable to different materials independently. Here is how you might modify your model:

   lme = fitlme(data_table, 'logxi ~ logH + Material + (1|Material:key)', ...
                'FitMethod', 'REML', ...
                'CovariancePattern', {'Full', 'Diagonal'});

In this modified model, 1|Material:key allows you to estimate a random intercept for each combination of building material and building key, thus treating each material's influence independently while still accounting for the nested structure of your data. After fitting your model, you can extract the variance components associated with each random effect. This can be done using the `anova` function or by accessing the VarianceComponents property of your fitted LMM object:

   varComp = lme.VarianceComponents;

This will give you insight into how much variance is explained by the building and material interactions. To further validate your approach, consider comparing models with different structures using Akaike Information Criterion (AIC) or Bayesian Information Criterion (BIC). This will help you assess whether separating out materials leads to a significantly better fit compared to your original model. After obtaining your variance estimates, visualizing them can provide additional insights. You might create plots showing the distribution of logxi across different materials or boxplots comparing variability in responses across material types.

Make sure that your data meets the assumptions required for LMMs, including normality and homoscedasticity of residuals and consider using cross-validation techniques to assess the robustness of your findings across different subsets of your data.

Hope this helps.

  6 Kommentare
Umar
Umar am 1 Nov. 2024 um 1:54

Hi @Sofía Mendoza,

To address your concerns regarding the linear mixed-effects model and the specific results you are trying to achieve, let me break down the components of your model and the associated calculations step by step. The code snippet provided by you is to fit a linear mixed-effects model:

lme = fitlme(data_table, 'logxi ~ logH * Material + (1|key) + 
(1|key:Material)', ...'FitMethod', 'REML', ...
'CovariancePattern', {'Full', 'Diagonal'});

This model specifies that logxi (the response variable) is influenced by the interaction between logH and Material, while accounting for random effects associated with key and the interaction of key with Material. The key components of the model are

Fixed Effects: These are the coefficients that represent the average effect of the predictors on the response variable. In your output, you have estimates for the intercept, logH, and the different materials.

Random Effects: These account for variability in the data that is not explained by the fixed effects. The random effects structure you specified allows for different intercepts for each level of key and for each combination of key and Material.

Covariance Parameters: The covariance structure you chose (Full, Diagonal) affects how the random effects are modeled. A full covariance structure allows for correlations between random effects, while a diagonal structure assumes no correlation.

To obtain the values in yellow from the initial table, you need to ensure that your model is correctly specified and that the data is appropriately pre-processed. Here are some steps to consider:

Data Preparation: Ensure that your data_table is correctly formatted and that there are no missing values in the variables used in the model. Missing data can lead to unexpected results.

Model Specification: Double-check the interaction terms in your model. If you suspect that the interaction between logH and Material is not being captured correctly, consider simplifying the model or testing each term individually.

Calculating Delta (δ) or Sigma (σ): The equation you provided for calculating sigma involves the variances of the fixed effects and the residuals. You can extract these from the model output.

Now, let me address your query regarding clarification on random number generation

   randn(numBuildings, 1) * 0.5;

This generates a vector of random numbers from a standard normal distribution (mean = 0, standard deviation = 1) and scales them by 0.5. This is often used to simulate random effects or noise in your model. If you want to incorporate random effects into your model, you can use this to simulate variability among buildings.

The last query to address the role of function Y , you mentioned it likely represents the response variable in your model. In the context of mixed-effects models, Y would be the observed values of logxi that you are trying to predict based on the fixed and random effects specified in your model.

Hope this helps.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by