1.7 Regression tables with {gtsummary}

Slides

Open the slides in a new tab here.

Exercises

  1. Download the R script here and put it into your in-class project folder.
  2. Run the examples.
  3. Each of the univariate regression examples held the outcome (y =) constant, while varying the predictor variables with include =. You can also look at one predictor across several outcomes. Create a univariate regression table looking at the association between sex (sex_cat) as the x = variable and each of nsibs, sleep_wkdy, and sleep_wknd, and income.
  4. 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.
  5. 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"). Regress glasses on eyesight_cat sex_cat and create a table showing the risk ratios and confidence intervals from this regression.
  6. 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 using tidy_fun = partial(tidy_robust, vcov = "HC1"). It will prompt you to install new package(s) (yes!). See this page for more on custom tidiers.
  7. Make a table comparing the log-binomial and the log-Poisson results.

Resources