[R-sig-ME] glmer model with independent random effects

Steve Walker steve.walker at utoronto.ca
Wed Jun 4 14:09:19 CEST 2014


Odd.  I get no problems on the current version of lme4 on CRAN.  Can you 
reproduce your problem with the example below?  If so, is it possible to 
update?

Steve


library(lme4)
set.seed(1)
m <- 50
n <- m^2
form <- y~ x1 + x2+(1|studyid) + ( x1 -1|studyid)+( x2 -1|studyid)

dat <- data.frame(studyid = gl(m, m),
                   x1 = rbinom(n, 1, 0.5), x2 = rbinom(n, 1, 0.5),
                   y = rep(0:1, length = n))

pars <- list(beta = setNames(1:3, c("(Intercept)", "x1", "x2")),
              theta = setNames(rep(1, 3), c("studyid.(Intercept)", 
"studyid.x1", "studyid.x2")))

dat$y <- unlist(simulate(form, newdata = dat, newparams = pars, family = 
binomial))

glmer(form, dat, binomial)

Generalized linear mixed model fit by maximum likelihood (Laplace
   Approximation) [glmerMod]
  Family: binomial ( logit )
Formula: y ~ x1 + x2 + (1 | studyid) + (x1 - 1 | studyid) + (x2 - 1 |
     studyid)
    Data: dat
       AIC       BIC    logLik  deviance  df.resid
1499.5705 1534.5148 -743.7852 1487.5705      2494
Random effects:
  Groups    Name        Std.Dev.
  studyid   (Intercept) 0.8685
  studyid.1 x1          0.7900
  studyid.2 x2          0.6559
Number of obs: 2500, groups: studyid, 50
Fixed Effects:
(Intercept)           x1           x2
      0.6693       1.8733       2.8996

sessionInfo()

R Under development (unstable) (2014-03-08 r65144)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] lme4_1.1-6   Rcpp_0.11.1  Matrix_1.1-3 mysys_1.0

loaded via a namespace (and not attached):
[1] compiler_3.1.0      grid_3.1.0          lattice_0.20-27
[4] MASS_7.3-29         minqa_1.2.2         nlme_3.1-113
[7] RcppEigen_0.3.2.1.2 splines_3.1.0       tools_3.1.0


On 2014-06-04, 7:34 AM, Thomas Debray wrote:
> Dear userlist,
>
> I recently updated the lme4 package to version 1.0-6 and have the
> impression formulas are not interpreted exactly the same way as before.
>
> I am trying to fit a mixed effect model with independent random effects for
> the covariates, that is:
>
> logit(y_ij) = b_0i + b_1i x1_ij + b_2i x2_ij
> where
> b_0i ~ N(beta0, tau0)
> b_1i ~ N(beta1, tau1)
> b_2i ~N(beta2, tau2)
>
> i indicates the subject, j indicates an index of different study IDs.
>
> In want to specify random slopes for b1 and b2, and a random intercept for
> b0. The variables x0 and x1 are binary, and take values 0 or 1. I have
> constructed the following formula:
>
> "y~ x1 + x2+(1|studyid) + ( x1 -1|studyid)+( x2 -1|studyid)"
>
>
> In one of the earlier versions of lme4, I would have gotten something like this:
>
>
> Random effects:
>   Groups    Name        Std.Dev.
>   studyid   (Intercept) 2.217e-04
>   studyid.1 x1        2.518e-05
>   studyid.2 x2     8.891e-05
>
>
> where tau0, tau1 and tau2 are indicated by the Std.Dev. Now, in the latest
> version of lme4 I get:
>
>
> Random effects:
>   Groups    Name        Std.Dev.  Corr
>   studyid   (Intercept) 2.217e-04
>   studyid.1 x10        2.518e-05
>             x11        4.480e-04 0.08
>   studyid.2 x20     8.891e-05
>
>             x21     1.108e-04 0.79
>
>
>
> Can someone tell me whether I am doing something wrong, or how I
> should adjust my formula to estimate the specified model?
>
>
> Thanks in advance!
>
>
> Thomas
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>



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