[R-sig-ME] lme4: qqmath.ranef.mer fails for lmer model with more than one random-effects term for a given grouping factor

Maarten Jung M@@rten@Jung @end|ng |rom m@||box@tu-dre@den@de
Wed May 15 14:18:47 CEST 2019


Dear Gerrit,

I encountered the same problem a while ago and wrote a custom function
based on this [1] SO post that should work (see plot-Re.txt attached).

Best regards,
Maarten

[1] https://stackoverflow.com/a/16511206




On Wed, May 15, 2019 at 2:03 PM Gerrit Eichner
<gerrit.eichner using math.uni-giessen.de> wrote:
>
> Dear lme4-experts,
>
> for an lmer model with more than one random-effects term for a
> given grouping factor as in the following example taken from
> qqmath.ranef.mer's help page
>
> fm2 <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject),
>              sleepstudy)
>
> "caterpillar plots" of the random effects applying dotplot,
> i.e., dotplot.ranef.mer, to the result of a call to ranef
> with condVar = TRUE appear as expected:
>
> dotplot(ranef(fm2, condVar = TRUE))
>
>
> But trying the analogue for the respective Q-Q plots using qqmath,
> i.e., qqmath.ranef.mer, throws an error:
>
> qqmath(ranef(fm2, condVar = TRUE))
>
> Error in seq_len(d[1]) :
>    argument must be coercible to non-negative integer
> In addition: Warning message:
> In seq_len(d[1]) : first element used of 'length.out' argument
>
>
> Does anyone happen to already have a work-around for this?
>
> (It appears to me that the problem originates in the structure
> of the postVar attribute of ranef(fm2, condVar = TRUE) in contrast
> to its structure of ranef(fm1, condVar = TRUE) where fm1 <-
> lmer(Reaction ~ Days + (Days|Subject), sleepstudy).)
>
> Thanks for any hints.
>
>   Best regards  --  Gerrit
>
> PS: sessionInfo()
>
> R version 3.5.3 (2019-03-11)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 10 x64 (build 17763)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
> [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
> [5] LC_TIME=German_Germany.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] ggplot2_3.1.1   lattice_0.20-38 lme4_1.1-21     Matrix_1.2-17
>
> loaded via a namespace (and not attached):
>   [1] Rcpp_1.0.1       magrittr_1.5     splines_3.5.3    MASS_7.3-51.3
>   [5] tidyselect_0.2.5 munsell_0.5.0    colorspace_1.4-1 R6_2.4.0
>   [9] rlang_0.3.4      minqa_1.2.4      plyr_1.8.4       dplyr_0.8.0.1
> [13] tools_3.5.3      grid_3.5.3       gtable_0.3.0     nlme_3.1-137
> [17] withr_2.1.2      assertthat_0.2.1 lazyeval_0.2.2   tibble_2.1.1
> [21] crayon_1.3.4     purrr_0.3.2      nloptr_1.2.1     glue_1.3.1
> [25] labeling_0.3     compiler_3.5.3   pillar_1.3.1     scales_1.0.0
> [29] boot_1.3-20      pkgconfig_2.0.2
>
>
> ---------------------------------------------------------------------
> Dr. Gerrit Eichner                   Mathematical Institute, Room 212
> gerrit.eichner using math.uni-giessen.de   Justus-Liebig-University Giessen
> Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
> http://www.uni-giessen.de/eichner
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: plot-RE.txt
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20190515/467ea7fa/attachment.txt>


More information about the R-sig-mixed-models mailing list