tidy.risks {risks}R Documentation

Tidy model summaries for risks models

Description

Obtain a tibble (data frame) with parameters, coefficients, standard errors, confidence limits, and p-values. A column with the type of model fitted is added.

Usage

## S3 method for class 'risks'
tidy(
  x,
  conf.int = TRUE,
  conf.level = 0.95,
  bootrepeats = 1000,
  bootci = c("bca", "normal", "nonpar"),
  bootverbose = FALSE,
  exponentiate = FALSE,
  default = TRUE,
  ...
)

Arguments

x

Model

conf.int

Show confidence intervals?

conf.level

Optional. Confidence level. Defaults to 0.95.

bootrepeats

Optional. Number of bootstrap repeats. Applicable to models fitted via marginal standardization and bootstrapping (approach = "margstd_boot"). Defaults to 1000. Strongly recommended to increase repeats to >>1000.

bootci

Optional and applicable for approach = "margstd_boot" only. Type of bootstrap confidence interval:

  • "bca" Default. Parametric BCa (bias-corrected accelerated) confidence intervals.

  • "normal" Parametric normality-based confidence intervals, which require lower repeat numbers but are less accurate and may result in invalid results for ratios.

  • "nonpar" Non-parametric BCa confidence intervals, which should be used with caution because of the risk of sparse-data bias with non-parametric bootstrapping.

bootverbose

Optional. Add values of bootrepeats and bootci parameters and the jackknife-based Monte-Carlo error for the confidence limits (only for type = "bca") to the returned tibble? Defaults to FALSE.

exponentiate

Optional. Exponentiate coefficients and confidence limits? Defaults to FALSE. Setting exponentiate = TRUE is useful for relative risk models (log links).

default

Use default, normality-based confidence intervals? Defaults to TRUE. With default = FALSE, for binomial models only, profile likelihood-based confidence intervals can be calculated.

...

Passed on

Details

If multiple types of models are fitted, tidy() can be used to parameters for all models at once, in one tibble. The last column of the tibble includes the name of the model. See examples.

Value

tibble

Examples

# Define example data
library(broom)  # provides tidy() function
dat <- tibble::tibble(
  death    = c(rep(1, 54), rep(0, 138)),
  stage    = c(rep("Stage I", 7),  rep("Stage II", 26), rep("Stage III", 21),
               rep("Stage I", 60), rep("Stage II", 70), rep("Stage III", 8)),
  receptor = c(rep("Low", 2),  rep("High", 5),  rep("Low", 9),  rep("High", 17),
               rep("Low", 12), rep("High", 9),  rep("Low", 10), rep("High", 50),
               rep("Low", 13), rep("High", 57), rep("Low", 2),  rep("High", 6)))
# Fit and tidy the model
fit_rr <- riskratio(formula = death ~ stage + receptor, data = dat)
tidy(fit_rr)

# Marginal standardization,
# increase number of bootstrap repeats:

fit_rr <- riskratio(
  formula = death ~ stage + receptor, data = dat,
  approach = "margstd_boot")
tidy(fit_rr, bootrepeats = 2000)


# Multiple types of models fitted:

fit_rr <- riskratio(formula = death ~ stage + receptor, data = dat,
                    approach = "all")
tidy(fit_rr)


[Package risks version 0.4.2 Index]