[Mediation-information] Error when using mediate function with lme4 models

Kentaro Hirose hirose at Princeton.EDU
Wed Jan 22 00:52:33 CET 2014


Dear J-P, 

I think this is a problem of "lme4" package. Can you try the following example after updating both "mediation" and "lme4" packages? When you update "ime4", please use the following R command: 

install.packages("lme4", repos=c("http://lme4.r-forge.r-project.org/repos", getOption("repos")["CRAN"]))

which will produce lme4 version 1.1-4.  

----------------------------------------------------------------------------
library(mediation)
library(lme4)
              
data(student)

med.fit <- glmer(attachment ~ catholic + gender + income + pared + (1|SCH_ID), family = binomial(link = "logit"), data = student)

out.fit <- glmer(fight ~ catholic*attachment + gender + income + pared + (1 + attachment|SCH_ID), family = binomial(link = "logit"), data = student)

med.out <- mediate(med.fit, out.fit, treat = "catholic", mediator = "attachment")
summary(med.out)
----------------------------------------------------------------------------

If this example does not work, please let us know.

Best,
Kentaro


________________________________________
From: Kosuke Imai
Sent: Tuesday, January 21, 2014 11:03 AM
To: Jean-Philippe Laurenceau
Cc: mediation-information at r-forge.wu-wien.ac.at; Kentaro Hirose
Subject: Re: [Mediation-information] Error when using mediate function with lme4        models

Hi J-P,

  We are currently looking into this and will get back to you as soon as possible.

Thanks,
Kosuke

---------------------------------------------------------
Kosuke Imai               Office: Corwin Hall 036
Professor                 Phone: 609-258-6601
Department of Politics    Fax: 609-258-1110
Princeton University      Email: kimai at Princeton.Edu
Princeton, NJ 08544-1012  http://imai.princeton.edu
---------------------------------------------------------

On Jan 20, 2014, at 12:20 PM, Jean-Philippe Laurenceau <jlaurenceau at psych.udel.edu> wrote:

> Dear R mediation Folk—I would like to start by saying that I have been enjoying the functionality and flexibility of the mediation package that Kosuke, Dustin, Teppei, Luke, et al. have developed. Bravo and keep up the important work of disseminating this tool!
>
> Nevertheless, I ran into a surprising error just this morning when running mediate on some lme4 data runs. It looks like an issue with the coding rather than my data because I get the same error when running the multilevel modeling example on the “jobs” data from the reference manual. This is what I get:
>
> > model.m <- glmer(job_dich ~ treat + econ_hard + (1 | educ), family = binomial(link = "probit"), data = jobs)
> > model.y <- glmer(work1 ~ treat + job_dich + econ_hard + (1 + treat | occp), family = binomial(link = "probit"), data = jobs)
> > multilevel <- mediate(model.m, model.y, treat = "treat", mediator = "job_dich", sims=50, group.out="educ")
>
> Error in mvrnorm(sims, mu = MModel.coef, Sigma = MModel.var.cov) :  incompatible arguments
>
> I am still somewhat new to R, so any insights on what needs to be tweaked would be much appreciated.
>
> Best, J-P
>
> Jean-Philippe Laurenceau, Ph.D.
> Department of Psychology
> University of Delaware
> 110 Wolf Hall
> Newark, DE 19716-2577
> Voice: (302) 831-2309
> Fax: (302) 831-3645
> jlaurenceau at psych.udel.edu
>
> _______________________________________________
> Mediation-information mailing list
> Mediation-information at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/mediation-information


More information about the Mediation-information mailing list