# NOT RUN {
data(Rothman)
require(moonBook)
mytable(stroke ~ oc + ht, data = Rothman, show.total = TRUE)
mhor(stroke ~ ht/oc, data = Rothman)
## Model with standard interaction term:
model1 <- glm(stroke ~ ht*oc, data = Rothman, family = binomial)
glm_coef(model1)
## Model considering join exposure:
Rothman$join <- 0
Rothman$join[Rothman$oc == "Non-user" & Rothman$ht == "Yes"] <- 1
Rothman$join[Rothman$oc == "User" & Rothman$ht == "No"] <- 2
Rothman$join[Rothman$oc == "User" & Rothman$ht == "Yes"] <- 3
Rothman$join <- factor(Rothman$join, labels=c("Unexposed", "Hypertension", "OC user",
"OC and hypertension"))
require(sjlabelled)
Rothman$join <- set_label(Rothman$join, label = "Exposure")
mytable(stroke ~ join, data = Rothman, show.total = TRUE)
model2 <- glm(stroke ~ join, data = Rothman, family = binomial)
glm_coef(model2)
odds_trend(stroke ~ join, data = Rothman)$df
odds_trend(stroke ~ join, data = Rothman)$fig
# }
Run the code above in your browser using DataLab