mediation
mediation copied to clipboard
Error in if(!INT & isGam.y) { : the condition has length > 1
I recently updated R and my packages and the below code, which was previously working, is no longer working:
fit.dv <- lme4::lmer(opti3 ~ no_recalled_notes + N + condition + log(attempt) + log(attempt):N + (1|unique_melody_name), data = na.omit(main2))
fit.mediator <- lme4::lmer(no_recalled_notes ~ N + condition + log(attempt) + log(attempt):N + (1|unique_melody_name), data = na.omit(main2))
results <- mediation::mediate(fit.mediator, fit.dv, treat = c('N', 'condition'), mediator = 'no_recalled_notes')
The error is:
Error in if(!INT & isGam.y) { : the condition has length > 1
Good afternoon, I have a similar problem. Have you already resolved the issue?
Hi @evagrosfeld. Yes, I think it's because you can only have one treat
variable (I just noticed this in the documentation). I moved one of my treat
variables (condition
in my example above) to the covariates
argument, and it works now.
Were you trying to use two or more variables for treat
?
Indeed, I was. Thank you, inserting one of the treat variables as covariates variable solves the issue!