falkcarl / multilevelmediation

5 stars 1 forks source link

"Simple indirect effects" for moderated mediation #16

Closed toddvogel1628 closed 3 years ago

toddvogel1628 commented 4 years ago

Include code to specify levels of "W" to test the indirect effect at different levels of W (see example code below).

  1. (a + aw) (b + bw). Almost exactly. Fit one model. Then, just plug in different values for "w". I suppose it might more properly look like this: (a + ainteractionw) (b + binteractionw).

where "ainteraction" is the coefficient for one interaction term, and "binteraction" is the coefficient for the other interaction term. Sorry, I'd have to re-look at the code to remember the notation. This is what I meant by "simple indirect effect".

toddvogel1628 commented 4 years ago

Here's a little more detail on Carl's thoughts for implementing this (might need to create as separate issue(s)):

(regarding modmed.mlm): output is now a list, and look at the "pars" vector. Ideally, we want a wrapper function that would take the result of modmed.mlm as input, and also a value of "w" as input (maybe 0 as the default), and then compute the value of the indirect effect from the "pars" vector and spit that out as output from the wrapper function. Assume the values of "pars" are named so it won't break if the indexing or composition of the vector changes. And then export the function and some docs for it.

falkcarl commented 3 years ago

extract.modmed.mlm can now do this: 56dda186650af0cecbba0c60054c4211fc5e0176