lm_with_std: Creates a summary table comparing standardised and...

View source: R/lm_tables.R

lm_with_stdR Documentation

Creates a summary table comparing standardised and non-standardised linear models

Description

This function creates a summary table for lm models (including mice::mira objects containing lm-models) that shows a standardised and non-standardised version of the model side-by-side. Several pairs of such models can be compared side-by-side.

Usage

lm_with_std(
  mod,
  std_mod,
  conf_level = 0.95,
  fmt = "%.2f",
  statistic_vertical = FALSE,
  filename = NULL,
  model_names = NULL,
  show_nimp = FALSE,
  R2_change = FALSE,
  notes = list(NULL),
  apa_style = TRUE,
  stars = std_stars_pad,
  ...
)

Arguments

mod

A lm-model/mira object of lm models, with variables not standardised (or a list of such models)

std_mod

A lm-model/mira object of lm models, with standardised variables. Can be created with lm_std (or a list of such models)

conf_level

Confidence level to use for confidence intervals, defaults to .95

fmt

determines how to format numeric values

  • integer: the number of digits to keep after the period 'format(round(x, fmt), nsmall=fmt)'

  • character: passed to the ‘sprintf' function (e.g., ’%.3f' keeps 3 digits with trailing zero). See '?sprintf'

  • function: returns a formatted character string.

statistic_vertical

Should standard errors and CIs be shown below coefficients? Defaults to horizontal layout

filename

the file name to create on disk. Include '.html' extension to best preserve formatting (see gt::gtsave for details)

model_names

If several pairs of models are to be plotted side by side, indicate the label for each *pair* here

show_nimp

Logical. If mira objects are passed, this determines whether the number of imputations will be reported as a model statistic

R2_change

Logical. Report R2 change and F-test to compare models. Only implemented for comparing two pairs of models.

notes

List of notes to append to bottom of table. An explanation of significance stars is automatically added. If the std models were run with a helper function in this package, a note regarding the standardisation is also automatically added.

apa_style

Logical, should APA-style formatting be applied

stars

Named vector of significance stars and their thresholds, check 'rNuggets:::std_stars_pad' for default.

...

Arguments passed on to modelsummary::modelsummary

output

filename or object type (character string)

  • Supported filename extensions: .html, .tex, .md, .txt, .png, .jpg.

  • Supported object types: "default", "html", "markdown", "latex", "data.frame", "gt", "kableExtra", "huxtable", "flextable".

  • Warning: the 'output' argument cannot be used when customizing tables with external packages. See the 'Details' section below.

estimate

string or 'glue' string of the estimate to display (or a vector with one string per model). Valid entries include any column name of the data.frame produced by 'get_estimates(model)'. Examples:

  • "estimate"

  • "estimate (std.error)stars"

  • "estimate [conf.low, conf.high]"

coef_map

named character vector. Values refer to the variable names that will appear in the table. Names refer to the original term names stored in the model object, e.g. c("hp:mpg"="hp X mpg") for an interaction term. Coefficients that are omitted from this vector will be omitted from the table. The table will be ordered in the same order as this vector.

coef_omit

string regular expression. Omits all matching coefficients from the table using 'grepl(perl=TRUE)'.

coef_rename

named character vector. Values refer to the variable names that will appear in the table. Names refer to the original term names stored in the model object, e.g. c("hp:mpg"="hp X mpg") for an interaction term.

gof_map
  • NULL (default): the 'modelsummary::gof_map' dictionary is used for formatting, and all unknown statistic are included.

  • data.frame with 3 columns named "raw", "clean", "fmt". Unknown statistics are omitted. See the 'Examples' section below.

  • list of lists, each of which includes 3 elements named "raw", "clean", "fmt". Unknown statistics are omitted. See the 'Examples section below'.

gof_omit

string regular expression. Omits all matching gof statistics from the table (using 'grepl(perl=TRUE)').

add_rows

a data.frame (or tibble) with the same number of columns as your main table. By default, rows are appended to the bottom of the table. You can define a "position" attribute of integers to set the row positions. See Examples section below.

align

A character string of length equal to the number of columns in the table. "lcr" means that the first column will be left-aligned, the 2nd column center-aligned, and the 3rd column right-aligned.

title

string


LukasWallrich/rNuggets documentation built on Aug. 26, 2022, 11:03 a.m.