tab_coefs: Tabulate model using ilr pivot coordinate method

View source: R/tables_of_coefficients.R

tab_coefsR Documentation

Tabulate model using ilr pivot coordinate method

Description

This pulls out a table of the coefficients of the models. Confidence intervals are calculated using 'confint'. The function may fail for logistic regression if the MASS package is not installed.

Usage

tab_coefs(
  scale_type = "lp",
  level = 0.95,
  type = NULL,
  outcome = NULL,
  covariates = NULL,
  follow_up_time = NULL,
  event = NULL,
  data,
  comp_labels,
  rounded_zeroes = TRUE,
  det_limit = NULL
)

Arguments

scale_type

Can take value "lp" (linear predictors) or "exp" (exponentiated- relevant for interpretation of logistic and Cox models).

level

The level argument of the confidence intervals. Passed directly to 'stats::confint'.

type

Type of statistical model to use. It should be one of "linear", "logistic", "cox".

outcome

Column name of outcome variable in data. If type is "linear", this should be a continuous variable. If type is "logistic", this should be a binary outcome. If type is "cox", if this is set it should be a Surv object from package survival (if it is set, the function defaults to attempt to use it, even if follow_up_time and event are set). If this is left as NULL, follow_up_time and event can be set instead.

covariates

Character vector of column names of covariates to adjust models for. As this is used as a character vector, special arguments to the standard models (like "strata(variable)" for a Cox model) can be used here.

follow_up_time

Only used if type is "cox" and outcome is NULL. Follow-up time.

event

Only used if type is "cox" and outcome is NULL.Binary variable indicating whether or not an event was observed.

data

Dataset to use for modelling.

comp_labels

The labels of the compositional columns.

rounded_zeroes

Are zeroes rounded zeroes?

det_limit

Detection limit if zeroes are to be imputed. This is needed when rounded_zeroes is TRUE. It should be the minimum measurable value in the compositional columns of data, and should be on the same scale as the (input) compositional columns. If rounded_zeroes is TRUE and there are zero values in the data, it throws an error. If the compositional columns do not have a constant sum, it also throws an error, as it cannot be automatically rescaled. Embedded zero imputation is for convenience only. It may be advisable to perform zero imputation prior to working with the data, particularly in more complex cases.

Value

Table of all model coefficients (parameter value with lower and upper confidence interval of the 95

Examples

tab_coefs(scale_type = "lp", # This argument can be "lp" or "exp" and determines whether
# coefficients are presented on the scale of the linear predictors ("lp")
# or are exponentiated ("exp"). Exponentiation gives the Odds Ratio for
# logistic regression models and the Hazard Ratio for Cox regression models.
level = 0.95,
type = "linear",
outcome = "BMI",
covariates = c("agegroup", "sex"),
data = simdata,
comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep" ),
rounded_zeroes = FALSE
)

OxWearables/epicoda documentation built on Dec. 7, 2022, 9:07 p.m.