Mediation analysis with mma() package in R error: Error in Anova.III.LR.glm(mod, singular.ok = singular.ok)

I am trying to run a mediation analysis with multiple parallel mediators using the mma() package in R. However, every time I try to run my code below, I am getting an error:


vcsqi <-
vcsqi <- vcsqi[, c("predmort", "age", "male", "bmi")]
vcsqi <- na.omit(vcsqi)
x = vcsqi
y = vcsqi[,"predmort"]
pred = vcsqi[,"bmi"]

test <- mma(x, y, pred=pred, mediator=c(2,3))

and this is the error I get:

Error in Anova.III.LR.glm(mod, singular.ok = singular.ok) : 
  there are aliased coefficients in the model

I understand that this error typically suggests multicollinearity or an issue with linearly dependent variables. However, I am not sure how to address this issue in the context of the mma() function or the data I am working with. I've checked for multicollinearity among my variables and didn't find any high correlations that would cause concern.

I am interested in examining the mediation effects of 'age' and 'male' on the relationship between 'bmi' (predictor) and 'predmort' (outcome).

Could anyone provide insight into why I might be receiving this error and how I might resolve it to successfully run my mediation analysis? Your help would be greatly appreciated. Thank you!

Example of how the code should be running:



For Categorical Exposure(s): [1] "pred"

 MMA Analysis: Estimated Mediation Effects Using GLM
     y1.all y1.exercises y1.sweat y1.sports
pred  0.116      -0.0286   0.0118     0.165



This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.