Cat_plot in r: Does it work with a poisson regression?

36 Views Asked by At

I am considering using cat_plot in r to visualize interactions between two categorical variables.

However, do any of you know wheter it work on a poisson regression model?

e.g.:

model <- glm(event ~ sex * year + offset(log(PY)), family = poisson(link = "log"), data = data1)
1

There are 1 best solutions below

0
jpsmith On

Example data:

df <- data.frame(outcome = rpois(100, 6),
                 covar1 = as.factor(sample(1:4, 100, replace = TRUE)),
                 covar2 = as.factor(sample(LETTERS[1:2], 100, replace = TRUE)))

Example Model

model <- glm(outcome ~ covar1 * covar2, family = poisson(link = "log"), data = df)

Plot

interactions::cat_plot(model, pred = covar1, modx = covar2)

enter image description here