[R-sig-ME] Zero slope-slope covariance models in lme4

Elliott, Lewis L@R@E|||ott @end|ng |rom exeter@@c@uk
Thu Mar 14 12:05:51 CET 2019


Dear all,

I have been attempting to fit glmer model objects in lme4 with correlated random intercepts and slopes. A minimal reproducible example of my situation might be:

require(tidyverse)
require(lme4)

dat <- mtcars %>%
  as_tibble() %>%
  mutate_at(vars(am,vs,gear,carb), all_vars(factor(.))) %>%
  select(am,vs,gear,carb)

fit <- glmer(am ~ vs + gear + (vs + gear|carb),
             dat=dat, family="binomial",control=glmerControl(calc.derivs=F), nAGQ=0)

However, the output of VarCorr:

Groups      Name        Std.Dev.    Corr
carb        (Intercept) 1.0938
vs1         1.0955      0.082
gear4       1.1446      0.080       0.294
gear5       1.0308      -0.037      -0.010      0.013

...fits correlations between all random slope terms. I am only interested in intercept-slope correlations and not slope-slope correlations.

In other words, I wish to constrain all correlations that are not intercept-slope correlations (i.e. all possible slope-slope correlations) to zero.

I have read the excellent advice on how to do this on Stack Overflow<https://stackoverflow.com/questions/35399127/lme4-how-to-specify-2-correlations-with-random-intercept-without-adding-correl/35401176#35401176> and in Appendix A.1 of the 2015 publication in Journal of Statistical Software ("Fitting Linear Mixed-Effects Models Using lme4") on how to do this using modular functions.

However, both of the examples given only demonstrate how to constrain one slope-slope correlation to zero. Is there a general way of constraining multiple (all) slope-slope correlations to zero using a similar method to those described on Stack Overflow and in the publication?

N.B In reality I have a large number of random slope terms specified in various models which are all factor variables with varying numbers of levels. This is why I'm looking for a general way rather than a way that is specific to each variance-covariance matrix for every model. I believe a solution might involve 'looping' over all non-first-row/first-column elements of the variance-covariance matrix and constraining these to zero, but I can't get my head around how this might be done.

My thanks in advance (and apologies for using correlation and covariance so interchangeably above).

Lewis

	[[alternative HTML version deleted]]



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