doomlab / MeMoBootR

A package for mediation, moderation, and bootstrapped indirect effects
MIT License
22 stars 7 forks source link

mediation1 #1

Closed mvantieghem closed 6 years ago

mvantieghem commented 6 years ago

Thanks for these great tutorials. I just followed your youtube video for mediation1, but my output is different. for example, when showing "model$boot.results" i have 2 lines of output that give results at 2 different levels of cyl (cyl6 and cyl8). i don't think i turned on this function, since i made sure the model was identical to that in your script in the video... Is this an intentional change in the output of the mediation1?

doomlab commented 6 years ago

Hi @mvantieghem!

If you run the example mediation 1 R, you should see the results that are shown in the video.

For example, I just reran the example and got:

> saved$boot.results

ORDINARY NONPARAMETRIC BOOTSTRAP

Call:
boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
    formula3 = allformulas$eq3, x = x, med.var = m)

Bootstrap Statistics :
      original     bias    std. error
t1* -0.7154021 0.05731329   0.5355541

However! If you run example mediation 1 cat R - you will get the two different slopes because the example makes the cyl variable categorical to show you how categorical mediation runs.

> saved$boot.results

ORDINARY NONPARAMETRIC BOOTSTRAP

Call:
boot(data = finaldata, statistic = indirectmed, R = nboot, formula2 = allformulas$eq2, 
    formula3 = allformulas$eq3, x = x, med.var = m)

Bootstrap Statistics :
     original      bias    std. error
t1* -2.665197 -0.02648852   0.9276959
t2* -5.492777 -0.04113382   1.3484901

Potentially, your output is due to two issues: 1) You've either run one or both without clearing out the environment, so it assumes the variable is categorical --> clear out the environment window by clicking on the broom in Rstudio or run rm(list = ls()) in the console. 2) You've managed to sync the package when I was messing around and updating (I don't think so, given the date you asked, but still worth checking), try reinstalling devtools::install_github("doomlab/MeMoBootR").

Let me know if that fixed your problem!