kosukeimai / mediation

R package mediation
58 stars 29 forks source link

Multiple-trial binomial mediator: an inconsistency? #59

Open vbrazao opened 1 year ago

vbrazao commented 1 year ago

I'm running two mediations on the same data, once using prior (sampling) weights when fitting the models (through the survey package), and once without those prior weights (just using the glm() function). My outcome is binary. My mediator is a proportion out of 3, so I also pass 3 as the weights argument (or rather, the name of a column that is equal to 3 for every subject). When using the models fit with survey:svyglm() inside mediate(), there is no issue; however, when using the glm() models, mediate() complains that "weights on outcome and mediator models not identical".

After checking the documentation, I see that you're not supposed to use a multiple-trial binomial mediator, as that is not implemented yet. My question is, why does it work when the models are fit through survey::svyglm()? And can I trust those results at all?