I am trying to figure out how to get confidence intervals for odds ratios that were computed based on model fitted values from a logistic regression.
Here's an example with the basic idea:
#Load packages
library(vcd)
library(dplyr)
data(Arthritis)
#Create binary outcome for logistic regression
Arthritis$Y <- ifelse(Arthritis$Improved=="None", 0,1)
#Fit Model
fit <- glm(Y ~ Sex + Treatment, family=binomial, data=Arthritis)
#Create small set to predict on, get fitted values, SEs, and odds
df <- expand.grid(Sex=levels(Arthritis$Sex),
Treatment=levels(Arthritis$Treatment)) %>%
mutate(link=predict(fit, newdata=., type="link"),
se=predict(fit, newdata=., type="link", se.fit=T)$se.fit,
odds=exp(link))
#Odds ratio with 'Female, Placebo' as referent
df$OR <- df$odds/filter(df, Sex=="Female" & Treatment=="Placebo")$odds
Can I compute a confidence interval for the odds ratios? I've seen other responses showing how I can get a CI for the fitted estimates, but not for ratios based on those estimates. Thanks.