kosukeimai / mediation

R package mediation
58 stars 29 forks source link

mediate() wrongly quits on error when model was called using :: operator #3

Closed jacob-long closed 7 years ago

jacob-long commented 7 years ago

I am working on a package that takes user input and within its functions, uses lme4 to fit and return a "merMod" object.

I tried to pass these models to mediate and was getting a "mediator model is not yet implemented" error. Poking through the source code, I see why. There are a series of if statements like

if(isMer.m && getCall(model.m)[[1]]=="lmer")

The models I've passed it, though, have a different 1st element, such that getCall(model.m)[[1]] would be "lme4::lmer" rather than "lmer". Of course, mediate has the technical capacity to fit these models but just doesn't recognize them for what they are.

I think it may be as simple of a fix as changing the if statements to something like

if(isMer.m && class(model.m)[[1]]=="lmerMod")
k-hirose commented 7 years ago

Hi Jacob. Thank you for your comment. We will fix the problem in the next update.

Best, Kentaro