[R-sig-ME] Testing all random-effects correlations in lme4

Daniel Lüdecke d@|uedecke @end|ng |rom uke@de
Sun Mar 13 10:31:35 CET 2022


Dear Timothy,
we just recently implemented computing SEs and Cis using Wald approxmination
based on Ben's suggested approach in the parameters package (you can
construct intervals for the random effect parameters both for profile Cis
and Wald Cis). See an example here:
https://easystats.github.io/parameters/reference/model_parameters.merMod.htm
l

The function "model_parameters()" uses the delta-method to transform
standard errors for constructing the intervals around the log-transformed SD
parameters. These are than back-transformed, so that random effect
variances, standard errors and confidence intervals are shown on the
original scale. We decided to do this to ensure that the intervals are
within the correct bounds (i.e. CI for correlations is between -1 and +1,
and intervals for the SD parameters are positive).

This feature is currently only available in the GitHub version (for Wald Cis
of random effects, profiled Cis for random effects already works in the CRAN
version), so if you want to try out, you have to install the package like
this.

install.packages("remotes")
remotes::install_github("easystats/parameters")

And here's a reprex with your model (formatting may be messed up, unless you
have a monospaced font):

library(lme4)
#> Loading required package: Matrix
library(parameters)
dat <- read.csv("https://raw.githubusercontent.com/fpqq/w/main/d.csv")

m1 <- glmer(
  y ~ item_type * time + (0 + item_type | user_id),
  family = binomial,
  data = dat,
  control = glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e4))
)

model_parameters(m1)
#> # Fixed Effects
#> 
#> Parameter                                                 | Log-Odds |
SE |         95% CI |     z |      p
#>
----------------------------------------------------------------------------
---------------------------------
#> (Intercept)                                               |     0.09 |
0.06 | [-0.03,  0.21] |  1.50 | 0.133 
#> item type [multiple-choice vocabulary]                    |     3.12 |
0.84 | [ 1.47,  4.77] |  3.70 | < .001
#> item type [production grammar]                            |    -0.46 |
0.10 | [-0.65, -0.28] | -4.82 | < .001
#> item type [production vocabulary]                         |     1.26 |
0.13 | [ 1.00,  1.51] |  9.71 | < .001
#> time [Post-test]                                          |     0.72 |
0.08 | [ 0.58,  0.87] |  9.49 | < .001
#> item type [multiple-choice vocabulary] * time [Post-test] |     0.31 |
0.27 | [-0.22,  0.84] |  1.14 | 0.255 
#> item type [production grammar] * time [Post-test]         |     0.42 |
0.13 | [ 0.16,  0.68] |  3.21 | 0.001 
#> item type [production vocabulary] * time [Post-test]      |     0.36 |
0.15 | [ 0.07,  0.64] |  2.44 | 0.015 
#> 
#> # Random Effects
#> 
#> Parameter                                           | Coefficient |   SE
|       95% CI
#>
----------------------------------------------------------------------------
-----------
#> SD (item_typemultiple-choice_grammar: user_id)      |        1.17 | 0.07
| [1.03, 1.32]
#> SD (item_typemultiple-choice_vocabulary: user_id)   |        3.41 | 0.70
| [2.28, 5.11]
#> SD (item_typeproduction_grammar: user_id)           |        1.45 | 0.12
| [1.23, 1.70]
#> SD (item_typeproduction_vocabulary: user_id)        |        1.77 | 0.17
| [1.47, 2.13]
#> Cor (Reference~item_typemultiple-choice_vocabulary) |        0.35 | 0.09
| [0.15, 0.52]
#> Cor (Reference~item_typeproduction_grammar)         |        0.38 | 0.06
| [0.25, 0.49]
#> Cor (Reference~item_typeproduction_vocabulary)      |        0.50 | 0.06
| [0.36, 0.62]
#> SD (Residual)                                       |        1.00 |
|
#> 
#> Uncertainty intervals (equal-tailed) and p values (two-tailed) computed
using a
#>   Wald z-distribution approximation.


Best
Daniel


-----Ursprüngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> Im
Auftrag von Ben Bolker
Gesendet: Freitag, 11. März 2022 17:37
An: Timothy MacKenzie <fswfswt using gmail.com>; R-mixed models mailing list
<r-sig-mixed-models using r-project.org>
Betreff: Re: [R-sig-ME] Testing all random-effects correlations in lme4

   [please keep r-sig-mixed-models in the cc: list]

   You can set the confidence intervals to be computed in parallel (see
?lme4::profile.merMod, the parallel arguments would get passed through as
part of the '...' argument from confint.merMod)

   Alternatively, you could use the merDerivs package, e.g.

library(lme4)
library(merDeriv)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) ## sd(int),
sd(days), cor(int,days), resid sdcor <-
as.data.frame(VarCorr(fm1))[["sdcor"]]
vv <- vcov(fm1, full = TRUE, ranpar = "sd") se <- sqrt(diag(vv))[c(3,5,4,6)]
## different order!

then construct the Wald CIs yourself

  I should really add something like this to broom.mixed, although Wald CIs
of random-effect parameters should come with a giant WARNING SIGN that says
they are often unreliable measures of uncertainty (which is why Doug Bates
didn't bother to implement them in the first place ...)

   cheers
    Ben Bolker



--

_____________________________________________________________________

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Joachim Prölß, Prof. Dr. Blanche Schwappach-Pignataro, Marya Verdel
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING



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