1.7 Regression tables with {gtsummary}
Slides
Open the slides in a new tab here.
Exercises
- Download the R script here and put it into your in-class project folder.
- Run the examples.
- Each of the univariate regression examples held the outcome (
y =) constant, while varying the predictor variables withinclude =. You can also look at one predictor across several outcomes. Create a univariate regression table looking at the association between sex (sex_cat) as thex =variable and each ofnsibs,sleep_wkdy, andsleep_wknd, andincome. - Fit a Poisson regression (
family = poisson()) for the number of siblings, using at least 3 predictors of your choice. Create a nice table displaying your Poisson regression and its exponentiated coefficients. - Instead of odds ratios for wearing glasses, as in the example, we want risk ratios. We can do this by specifying in the regression
family = binomial(link = "log"). Regressglassesoneyesight_catsex_catand create a table showing the risk ratios and confidence intervals from this regression. - Since
family = binomial(link = "log")often doesn’t converge, we often use Poisson regression with robust standard errors to estimate risk ratios. Fit a Poisson regression instead of the log-binomial regression in the last question. Then create a table usingtidy_fun = partial(tidy_robust, vcov = "HC1"). It will prompt you to install new package(s) (yes!). See this page for more on custom tidiers. - Make a table comparing the log-binomial and the log-Poisson results.