tbl_group_forests: Grouped Forest Plots

View source: R/gt.R

tbl_group_forestsR Documentation

Grouped Forest Plots

Description

Grouped Forest Plots

Usage

tbl_group_forests(
  object,
  formula,
  type,
  vars,
  level = list(),
  columns = list(beta ~ "Estimate", conf ~ "95% CI", n ~ "No."),
  flip = FALSE,
  axis = list(scale ~ "continuous"),
  width = list()
)

Arguments

object

A forge object that contains or represents model data, with required grouping variables (such as strata or interaction terms).

formula

Identifies the relationships of interest, with LHS representing the outcome, and RHS representing the exposure.

type

Character vector to identify if the model was using subgroups or interaction terms. The difference is that confidence intervals for interaction can be calculated in multiple ways, and the effect size is dependent on the presence or absence of the interaction variable.

  • interaction = assumes an interaction term that is binary/dichotomous

  • subgroup = assumes a categorical variable that was used to group the original dataset

vars

Character vector of the variables of interest. They can either be grouping variables, or can be performed as interaction terms (based on the models included originally). If the parameter interaction is changed to TRUE, then will create joint confidence intervals for the presence or absence of the interaction term.

level

List of formulas. Each list-element is a formula with the LHS reflecting either the variable to re-label or a specific level, and the RHS reflecting what the new level should be called (for display). If there are conflicting labels, the most recent will be used.

For example, ⁠list(am ~ c("Manual", "Automatic")⁠ would take, from the mtcars dataset, the am variable, which consists of c(0, 1), and relabel them in the order described. They are sorted in ascendiing order prior to re-labeling.

The alternative approach is to use the specific level itself and have it re-labeled. list(0 ~ "Absent") would take all levels that are zero, and change their value.

columns

Additional columns that help to describe the subgroup models. At least one column should be selected from this list. The sequence listed will reflect the sequence shown in the table. The current options are:

  • beta = point estimate value, such as odds ratio or hazard ratio

  • conf = inclusion of the confidence interval (presumed to be 95%-ile)

  • n = number of observations in each model group

  • p = p.value for model or interaction term

For example: ⁠list(beta ~ "Hazard", conf ~ "95% CI" n ~ "No.")"⁠

flip

Determine if the odds or hazard ratio should be shown as the reciprocal values. Instead of a decreasing hazard for every unit increase, it describes an increasing hazard for every unit decrease.

axis

Argument to help modify the forest plot itself. This is a list-formula of the following parameters. If they are not named, the function will attempt to "guess" the optimal parameters. The options are:

  • title = label or title for the column describing the forest plot

  • lim = x-axis limits

  • breaks = x-axis tick marks or break points that should be numbers

  • int = x-axis intercept

  • lab = label for the x-axis

  • scale = defaults to continuous, but may also use a log transformation as well c("continuous", "log")

For example: ⁠list(title ~ "Decreasing Hazard", lab ~ "HR (95% CI))⁠

width

Describes the width of each column in a list of two-sided formulas. The RHS is a decimal reflecting the percent each column should take of the entire table. The forest plot is usually given 30% of the width.

For example: list(n ~ .1, forest ~ 0.3)


asshah4/durandal documentation built on Sept. 22, 2023, 9:02 p.m.