I need help calculating/ using a package to break down the interaction and obtain the correct odds ratios.
Here is some sample code of what I already have.
library(ggeffects)
library(interactions)
library(sjPlot)
library(ggplot2)
arm = rep(c(0,1), times = 50)
shared = rep(c(0,1,1,0), times = 25)
set.seed(2)
tested = sample(c(0,1), replace = TRUE, size = 100)
d = data.frame(arm,shared,tested)
d$arm = as.factor(d$arm)
d$shared = as.factor(d$shared)
M = glm(tested ~ arm*shared, data = d, family = binomial())
summary(M)
tab_model(M, show.aic = TRUE, show.loglik = TRUE)
cat_plot(M, pred = shared, modx = arm, outcome.scale = "odds", y.label = "odds")
ggpredict(M, c("arm", "shared"))
Output:
I used tab_model to get the odds ratios for each predictor and the overall interaction and cat_plot to visualize the interaction. I used ggpredict to get the predicted values for each part of the interaction (however, I don't full understand how to interpret those).
But I can't seem to figure out how to break down the interaction and calculate those correct odds ratios (such as the odds for arm=1 compared to arm=0 only for inject=1).
For example, how do I calculate the value for "X" in: "the odds that a 'arm=1' and 'shared=1' person has been tested is X times the odds of someone who is 'arm=0' and 'shared=1'.
Thanks so much for any help! I don't have a great grasp on calculating odds ratios for interactions.



