Not sure if the question is suitable to ask here.
Calculating odds ratio with interaction term in R using exp() function:
For example, If I take exponent of the coefficients which would give me odds ratio. It works fine for the predictors with no interaction. However, my question is if the interaction term is included and we take exp() function on the coefficient, is the odds ratio for the interaction term (y:z) correct?
Thanks
x <- sample( c(0,1), 20, replace=TRUE, prob=c(0.1, 0.52))
y <- sample( c(0,1), 20, replace=TRUE, prob=c(0.3, 0.52))
z <- sample( c(0,1), 20, replace=TRUE, prob=c(0.15, 0.04))
df<-data.frame(cbind(x,y,z))
model=glm(x~y*z,data=df,family=binomial(link="logit"))
summary(model)
exp(cbind(Odds_and_OR=coef(model), confint(model)))
###################################################
output:
Call:
glm(formula = x ~ y * z, family = binomial(link = "logit"), data = df)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8930 0.4530 0.6360 0.6681 0.9005
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.6094 1.0954 1.469 0.142
y -0.2231 1.3509 -0.165 0.869
z -0.9163 1.6432 -0.558 0.577
y:z 17.0961 3956.1807 0.004 0.997
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 20.016 on 19 degrees of freedom
Residual deviance: 19.234 on 16 degrees of freedom
AIC: 27.234
Number of Fisher Scoring iterations: 16
>
> exp(cbind(Odds_and_OR=coef(model), confint(model)))
Waiting for profiling to be done...
Odds_and_OR 2.5 % 97.5 %
(Intercept) 5.0 8.063919e-01 95.79539
y 0.8 3.208724e-02 10.71957
z 0.4 1.106609e-02 13.61758
y:z 26590507.7 6.838652e-265 NA