tbl_propdiff: Calculating unadjusted and adjusted differences in rates

Description Usage Arguments Value Methods Examples

View source: R/tbl_propdiff.R

Description

This function calculates the unadjusted or adjusted difference in rates with confidence interval.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tbl_propdiff(
  data,
  y,
  x,
  formula = "{y} ~ {x}",
  label = NULL,
  statistic = "{n} ({p}%)",
  method = c("chisq", "exact", "boot_sd", "boot_centile"),
  conf.level = 0.95,
  bootstrapn = ifelse(method == "boot_centile", 2000, 200),
  estimate_fun = style_sigfig,
  pvalue_fun = style_pvalue
)

Arguments

data

A data frame

y

vector of binary outcome variables. Outcome variables can be numeric, character or factor, but must have two and only two non-missing levels

x

string indicating the binary stratifying variable. The stratifying variable can be numeric, character or factor, but must have two and only two non-missing levels

formula

By default, "{y} ~ {x}". To include covariates for an adjusted risk difference, add covariate names to the formula, e.g. "{y} ~ {x} + age"

label

List of formulas specifying variables labels, If a variable's label is not specified here, the label attribute (attr(data$high_grade, "label")) is used. If attribute label is NULL, the variable name will be used.

statistic

Statistics to display for each group. Default "{n} ({p}%)"

method

The method for calculating p-values and confidence intervals around the difference in rates. The options are "chisq", "exact", "boot_centile", and "boot_sd". See below for details. Default method is "chisq".

conf.level

Confidence level of the returned confidence interval. Must be a single number between 0 and 1. The default is a 95% confidence interval.

bootstrapn

The number of bootstrap resamples to use. The default is 2000 for "boot_centile" and 200 for "boot_sd"

estimate_fun

Function to round and format estimates. By default style_sigfig, but can take any formatting function

pvalue_fun

Function to round and format p-value. By default style_pvalue, but can take any formatting function

Value

A tbl_propdiff object, with sub-class "gtsummary"

Methods

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
tbl_propdiff(
  data = trial,
  y = "response",
  x = "trt"
)

tbl_propdiff(
  data = trial,
  y = "response",
  x = "trt",
  formula = "{y} ~ {x} + age + stage",
  method = "boot_sd",
  bootstrapn = 25
)

ddsjoberg/hotfun documentation built on Dec. 12, 2021, 3:41 a.m.