Does anyone have any experience with the mediations package in r?
In attempting to mediate one variable on multiple IV's on one DV (equation below)
Treatments <- c(Iv1, Iv2)
Mediators <- mediatorvariable
Outcomes <- DV
mediatormodel <- medaitons(Dataframe, treatments = Treatments, mediator = Mediators, outcome = Outcomes, covariates = NULL, boot = TRUE, sims = 500)
I'm experiencing this error:
Error in rep(1, nrow(dataarg)) : invalid 'times' argument
None of my variables include negative #'s, and I've removed any NA's from my data frame (e.g., all my variables have the same # of rows)
From any of the sources, I've found explain that this r-package does not support multiple medications (which is counterintuitive since the mediations command was recently implemented for that specific reason) or that the mediator variable contains negative variables.
Has anyone here experienced and found a solution to this error?
Thanks!
In attempting to mediate one variable on multiple IV's on one DV (equation below)
Treatments <- c(Iv1, Iv2)
Mediators <- mediatorvariable
Outcomes <- DV
mediatormodel <- medaitons(Dataframe, treatments = Treatments, mediator = Mediators, outcome = Outcomes, covariates = NULL, boot = TRUE, sims = 500)
I'm experiencing this error:
Error in rep(1, nrow(dataarg)) : invalid 'times' argument
None of my variables include negative #'s, and I've removed any NA's from my data frame (e.g., all my variables have the same # of rows)
From any of the sources, I've found explain that this r-package does not support multiple medications (which is counterintuitive since the mediations command was recently implemented for that specific reason) or that the mediator variable contains negative variables.
Has anyone here experienced and found a solution to this error?
Thanks!
Edit - I was able to run this model with spss via Hayes PROCESS macro, so I can confirm that it does work. I’d like to keep this thread open for discussion in case anyone else experiences this problem in r. The script from Hayes should work similarly in the mediation package.
Essentially, one would individually run a mediation in a single Iv while using the others as covariates. This process would then be repeated for as many ive are included
Example:
Treatments1 <- Iv1
Treatments2 <- Iv2
Mediators <- mediatorvariable
Outcomes <- DV
Cov1 <- c(iv2, iv3... etc)
Cov2 <- c(iv1, iv3... etc)
mediatormodel <- medaitons(Dataframe, treatments = Treatments, mediator = Mediators, outcome = Outcomes, covariates = Cov1, boot = TRUE, sims = 500)
mediatormodel2 <- medaitons(Dataframe, treatments = Treatments2, mediator = Mediators, outcome = Outcomes, covariates = Cov2, boot = TRUE, sims = 500)
Etc