kosukeimai / mediation

R package mediation
58 stars 29 forks source link

Extending the package to GAMM? #14

Open Renemagne opened 5 years ago

Renemagne commented 5 years ago

Hi!

Thank you very much for providing the mediation package to R, I really enjoy working with it! I was wondering, however, if it is somehow possible to extend the mediation package to also accept GAMM models, in one way or another.

Being aware that "mediation" does not handle "gamm" models directly, I tried to circumvent the problem by implementing my design with the mgcv "gam" function by using bs="re" flag as specification (as suggested by S. Wood , https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/random.effects.html). Unfortunately, it appears that using this approach the "predict.gam" (as currently used in "mediation") fails, and I get the following error message:

"Error in predict.gam(new.fit.M, type = "response", newdata = pred.data.t) : 403, 407, 418, 421,..."

In advance, thank you for your time!

Best regards René