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.
Thank you Rui!! Very good your explanation and solution!
– user55546