## Not run:
# mod1 <- lm(wage ~ age * sex + sector, data = mosaicData::CPS85)
# fmodel(mod1)
# fmodel(mod1, ~ sector + sex + age) # not necessarily a good ordering
# # show the data used for fitting along with the model
# fmodel(mod1, ~ age + sex + sector, nlevels = 8) +
# ggplot2::geom_point(data = mosaicData::CPS85, alpha = 0.1)
# require(ggplot2)
# fmodel(mod1, ~ age + sex + sector, nlevels = 8) +
# geom_point(data = mosaicData::CPS85, alpha = 0.1) +
# ylim(0, 20)
# mod2 <- lm(log(wage) ~ age + sex + sector, data = mosaicData::CPS85)
# fmodel(mod2, post_transform = c(wage = exp)) # undo the log in the display
# mod3 <- glm(married == "Married" ~ age + sex * sector,
# data = mosaicData::CPS85, family = "binomial")
# fmodel(mod3, type = "response")
# # Adding the raw data requires an as.numeric() trick when it's TRUE/FALSE
# fmodel(mod3, ~ age + sex + sector, nlevels = 10, type = "response") +
# geom_point(data = mosaicData::CPS85,
# aes(x = age, y = as.numeric(married == "Married")), alpha = .1)
# ## End(Not run)
Run the code above in your browser using DataLab