'cat_plot showing same confidence intervals for all data points (interactions package in r)

I am using the cat_plot function from the [interactions]https://interactions.jacob-long.com/reference/cat_plot.html package to plot a 2-way interaction between two categorical variables.

I have the following syntax:

set.seed(123)

cat_1 <- rep(c("A", "B", "C"), length.out = 150)
cat_2 <- rep(c("X", "Y"), each = 3, times = 25)

outcome <- round(rtruncnorm(n = 150,a = 1, b = 7,mean = c(5.7, 6.8, 3.1, 2.4, 6.9, 5.9), sd = c(1.8, 0.9, 1.5, 1.4, 1.1, 1.6)))

df <- data.frame(cat_1, cat_2, outcome)

glm_2way <- glm(outcome ~ cat_1*cat_2, data = df)

cat_plot(glm_2way, pred = cat_1, modx = cat_2, interval = TRUE,
         colors = "Rainbow")

Which gives me this graph:

enter image description here

Which shows exactly the same error bars for all the data points. The example given in the vignette with the diamonds package uses exactly the same syntax, cat_plot(fit, pred = color, modx = cut, interval = TRUE) but shows the correct error bars. What am I doing wrong?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source