In this recipe, we will use the robustlmm package to estimate robust linear mixed effects models. Its biggest advantage is that it uses the exact same syntax (and outputs) that the lmer function uses. We will evaluate what happens when we contaminate 5% of the data with abnormal values. As we will see, the lmer function suffers enormously with even a 5% contamination. The robustlmm package, on the contrary, does a great job, reporting coefficients almost as if no contamination had happened.
- First, we generate data for 100 groups, containing 10 members each. Then, we generate random Gaussian deviates that are pasted to the dataset. Each group will share a common random shock that will render all the observations from that ...