Heterocesarean mixed effects model via lmer function

Asked

Viewed 36 times

2

I am adjusting a mixed effects model which due to observed heterocedasticity was necessary to include an effect to accommodate it. For this purpose, using the function lme package nlme this was easy to solve, see the code below:

library(nlme)
library(lme4)
Model1 <- lme(log(Var1)~log(Var2)+log(Var3)+
                     (Var4)+(Var5),
                    random = ~1|Var6, Data1, method="REML",
                   weights = varIdent(form=~1|Var7))
#Var6: É um fator com diversos níveis.
#Var7: É uma variável Dummy.

However, I need to readjust the model described above using the package lme4, that is, using the function lmer. It is of knowledge and many are the materials that inform some limitations existing in the lme4, such as modelling heterocedhasity. What motivated me to readjust this model is the fact that I have an interest in using a specific package that in cases of mixed models it only accepts if these are adjusted through the function lmer. How could I possibly resolve this situation? Below is a good part of the adjusted model using the lmer function, however, this model is not considering the effect to model the observed heterocedase.

Model2 <- lmer(log(Var1)~log(Var2)+log(Var3)+
                          (Var4)+(Var5)+(1|Var6),
                    Data1, REML=T)

Dice: https://drive.google.com/file/d/1cr9-KOOR_RTDN4_nHizpvKBZ0yDAKGoV/view?usp=sharing

Regarding the choice of the random effect (Var6) and the inclusion of the effect to consider the heterogeneity by levels of the variable (Var7), these were analyzed carefully, however, I will not put here the whole procedure not to be an extensive post and be more objective.

1 answer

5


In a response from R-Sig-Mixed-models, Douglas Bates (Googlescholar, Researchgate) gives the following answer to a question on the possibility of modeling the problem of the distribution heteroscedasticity of the answer in mixed models.

As far as I know there is not yet the Capability in lme4 to model heteroscedasticity in the Distribution of the Response Given the Random effects.

Google Translation.

As far as I know, there is still no capacity in MI4 to model heterocedasticity in the distribution of the randomness response effects.

I think the best way is to cuddle Var7 the variable of random effects Var6. This is easy to do and a graph qqnorm makes a better fit than Model1 or Model2.

library(nlme)
library(lme4)

Model1 <- lme(log(Var1) ~ log(Var2) + log(Var3) + Var4 + Var5,
              random = ~1|Var6, Data1, method = "REML",
              weights = varIdent(form = ~1|Var7))

Model2 <- lmer(log(Var1) ~ log(Var2) + log(Var3) + Var4 + Var5 + (1|Var6),
               Data1, REML=TRUE)

The models above are those of the question, now the new model.

Model3 <- lmer(log(Var1) ~ log(Var2) + log(Var3) + Var4 + Var5 + (1|Var6/Var7),
               Data1, REML=TRUE)

The output of these commands has been omitted.

summary(Model1)
summary(Model2)
summary(Model3)

And finally the three graphs. Without interpretation, the Model3 is clearly the best option. Note the outlier of the residues in the first two graphs that it was not necessary to remove in the third model.

op <- par(mfrow = c(1, 3))
qqnorm(resid(Model1))
qqline(resid(Model1), col = "red")
qqnorm(resid(Model2))
qqline(resid(Model2), col = "red")
qqnorm(resid(Model3))
qqline(resid(Model3), col = "red")
par(op)

inserir a descrição da imagem aqui


Data reading

google_id <- "1cr9-KOOR_RTDN4_nHizpvKBZ0yDAKGoV"
google_file <- sprintf("https://docs.google.com/uc?id=%s&export=download", google_id)
Data1 <- read.csv2(google_file)
  • Thank you Rui!! Very good your explanation and solution!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.