I would like to calculate contrasts of predictive probabilities. In a nutshell, I would like to compute the difference in differences of probabilities. The code below illustrates exactly my problem.
Among men, I calculate the predictive probability of the event by smoking:
p1 = prob. of event|sex==1 and smoking == 1;
p2 = prob. of event|sex==1 and smoking == 0
Among women, I calculate the predictive probability of the event by smoking.
p3 = prob. of event|sex==0 and smoking == 1;
p4 = prob. of event|sex==0 and smoking == 0
Now, what I want to calculate is the (p4-p3)-(p2-p1) along with 95% CI. In the example below, the difference in differences would be around -0.06 [e.g., (0.44-0.5)-(0.52-0.52)]. How do we estimate the SE/95% CI for that difference in R?
library(ggeffects)
N = 100
set.seed(123456)
hypertension <- round(runif(N))
age <- rnorm(N,45,5)
sex <- round(runif(N))
smoking <- round(runif(N))
model <- glm(hypertension ~ age + sex + smoking +sex*smoking, family = "binomial")
summary(model)
ggpredict(model, c("smoking", "sex"))
Thank you so much for any tips/suggestions.
All the best,
Jacob