jmpsteen / medflex

Flexible mediation analysis using natural effect models in R
23 stars 6 forks source link

Using VGAM for neModel #20

Closed ellenxtan closed 3 years ago

ellenxtan commented 4 years ago

Thanks for creating this great package! I was wondering if the package could deal with outcomes from a negative binomial distribution? It seems I could only specify family type in neImpute and neWeight, but could not do so in the neModel. For example: expData <- neImpute("day_delirium ~ haplogroup + med + age", family = negbinomial, data = whitemat, FUN=vglm) neMod <- neModel(day_delirium ~ haplogroup0 + haplogroup1, family = negbinomial, expData = expData, , FUN=vglm) Error: $ operator not defined for this S4 class

Thanks in advance!

jmpsteen commented 3 years ago

Thanks for your interest! Currently, medflex only allows generalized linear natural effect models to be fitted, which all use the glm functionality. In principle, I think you could extend this to a negative binomial natural effect model but then you have to directly fit this natural effect model using vglm on the imputed dataset (expData). Standard errors and CIs can then be obtained by manually coded bootstrap. Hope this helps!

I don't really consider this an issue, in the sense that the vignette (caption of Table 4) states this functionality is not offered by the package. If you agree, please close this issue.

Many thanks!

ellenxtan commented 3 years ago

Thanks!