From jlaurenceau at psych.udel.edu Mon Jan 20 18:44:54 2014 From: jlaurenceau at psych.udel.edu (Jean-Philippe Laurenceau) Date: Mon, 20 Jan 2014 12:44:54 -0500 Subject: [Mediation-information] Error when using mediate function with lme4 models Message-ID: <0478721FB7E8994C9425EEC863C8EC660128163990FE@razor.psych.udel.edu> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jlaurenceau at psych.udel.edu Mon Jan 20 18:20:27 2014 From: jlaurenceau at psych.udel.edu (Jean-Philippe Laurenceau) Date: Mon, 20 Jan 2014 12:20:27 -0500 Subject: [Mediation-information] Error when using mediate function with lme4 models Message-ID: <0478721FB7E8994C9425EEC863C8EC660128163990FD@razor.psych.udel.edu> 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kimai at Princeton.EDU Tue Jan 21 17:03:06 2014 From: kimai at Princeton.EDU (Kosuke Imai) Date: Tue, 21 Jan 2014 16:03:06 +0000 Subject: [Mediation-information] Error when using mediate function with lme4 models In-Reply-To: <0478721FB7E8994C9425EEC863C8EC660128163990FD@razor.psych.udel.edu> References: <0478721FB7E8994C9425EEC863C8EC660128163990FD@razor.psych.udel.edu> Message-ID: 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 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 From jlaurenceau at psych.udel.edu Wed Jan 22 02:41:47 2014 From: jlaurenceau at psych.udel.edu (Jean-Philippe Laurenceau) Date: Tue, 21 Jan 2014 20:41:47 -0500 Subject: [Mediation-information] Error when using mediate function with lme4 models Message-ID: <0478721FB7E8994C9425EEC863C8EC66012816399161@razor.psych.udel.edu> Dear Kentaro--I followed your directions and the example ran fine this time with no errors. So, it looks like it has something to do with the newest release of lme4 v 1.0-5. Perhaps it depends on the particular mirror that one selects, but the install.packages command that you sent me installed lme4 v 1.0-2, but it still worked. Thanks for your help! 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 -----Original Message----- From: Kentaro Hirose [mailto:hirose at Princeton.EDU] Sent: Tuesday, January 21, 2014 6:53 PM To: Kosuke Imai; Jean-Philippe Laurenceau Cc: mediation-information at r-forge.wu-wien.ac.at Subject: RE: [Mediation-information] Error when using mediate function with lme4 models 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 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 From hirose at Princeton.EDU Wed Jan 22 00:52:33 2014 From: hirose at Princeton.EDU (Kentaro Hirose) Date: Tue, 21 Jan 2014 23:52:33 +0000 Subject: [Mediation-information] Error when using mediate function with lme4 models In-Reply-To: References: <0478721FB7E8994C9425EEC863C8EC660128163990FD@razor.psych.udel.edu>, Message-ID: <7F71CA3EDBFDB742900C47C9596B9023364C9923@CSGMBX201W.pu.win.princeton.edu> 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 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