psychbruce / bruceR

📦 BRoadly Useful Convenient and Efficient R functions that BRing Users Concise and Elegant R data analyses.
https://psychbruce.github.io/bruceR/
GNU General Public License v3.0
167 stars 36 forks source link

Error in PROCESS when doing moderated multilevel mediation #15

Closed RichardJanzen closed 2 years ago

RichardJanzen commented 2 years ago

Hello Han-Wu-Shuang Bao,

first let me say that I am amazed at how Your package works. It is exactly what I was searching for for my masters thesis.

I was trying to do a moderated multilevel mediation (1-1-1), where the moderator had an effect on all paths: PROCESS( data_long_labs, y = "HO_sat", x = "HO_isol", meds = "HO_self", clusters = "ID", mods = "HO_cont_sup", mod.path = "all", nsim = 10)

The first part is being computed without problems, but when it starts to work on the simulations, it ends with the message: Error in.rowNamesDF<-(x, value = value) : invalid 'row.names' length

I tried it with a normal mediation at a single point in time, the multilevel mediation without the moderation and the moderation having an influence only on special paths + combinations of mod.path types. All of that worked perfectly fine, only the computation of the effect on all paths doesn't, also when supplied by c("x-y", "x-m", "m-y"), or even c("m-y", "x-y)". I updated my R, RStudio and all packages and closed the R-Session multiple times.

I hope, that You can solve this problem. I will be happy to help You if I can. Greetings from Germany! Richard

The Traceback returned: 11.stop("invalid 'row.names' length") 10..rowNamesDF<-(x, value = value) 9.row.names<-.data.frame(*tmp*, value = gsub(":", " x ", row.names(dp1))) 8.row.names<-(*tmp*, value = gsub(":", " x ", row.names(dp1))) 7.interaction_F_test(model, data = data, data.name = data.name) 6.interaction_test(model, data = data.c, data.name = "data.c") 5.process_mod(model.y0, model.y, data.c, x, y, mod1, mod2, mod1.val, mod2.val, mod.type, x.label = "X", y.label = "Y", eff.tag = "(Conditional Direct Effects [c'] of X on Y)", nsmall, file = file) at #1 4.eval(parse(text = text), envir = parent.frame()) 3.eval(parse(text = text), envir = parent.frame()) 2.Run(run.process.mod.xy(eff.tag = "(Conditional Direct Effects [c'] of X on Y)")) 1.PROCESS(data_long_labs, y = "HO_sat", x = "HO_isol", meds = "HO_self", clusters = "ID", mods = "HO_cont_sup", mod.path = c("m-y", "x-y"), nsim = 5)

psychbruce commented 2 years ago

Thanks for reporting this issue. Yes, it is a bug I did not notice before. The traceback you provided in the message helped me locate the problem quickly. Now I have fixed it and pushed a new commit to GitHub. You may update to the developing version of bruceR using devtools::install_github("psychbruce/bruceR", force=TRUE). I will close this issue.

RichardJanzen commented 2 years ago

Thank You very much! It works without problems now.