I have conducted a negative binomial regression and utilized the glm.nb function from the MASS-package. My model includes 2 interaction effects and I would therefore like to create interaction plots. I tried to use the interplot function from the interplot-package:
interplot(m = model, var1 = "aid1", var2 = "aid")**
interplot(m = model, var1 = "Adjusted.aid1", var2 = "Adjusted.aid2")**
However, I get the following error:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘sim’ for signature ‘"negbin"’
Does anyone know how I can create interaction plots for my model? Can I use interplot? Any help would be highly appreciated.
You can try the marginaleffects
package: (Disclaimer: I am the author.)
library(MASS)
library(marginaleffects)
mod <- glm.nb(gear ~ hp * drat, data = mtcars)
plot_cme(mod, effect = "hp", condition = "drat")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.