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

View source: R/lm_tables.R

polr_with_stdR Documentation

Creates a summary table comparing standardised and non-standardised proportional odd logistic regression models

Description

This function creates a summary table for polr models (including mice::mira objects containing polr-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

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

Arguments

mod

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

std_mod

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

OR

Logical. Shoulds odds ratios be shown instead of typical coefficients. If TRUE, estimates are exponentiated

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

notes

List of notes to append to bottom of table. An explanation of significance stars is automatically added. A note is also added stating that dummy variables were not scaled in standardization. If you approached standardisation differently, that should be removed.

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]"

vcov

robust standard errors and other manual statistics. The ‘vcov' argument accepts five types of input (see the ’Details' and 'Examples' sections below):

  • string, vector, or list of strings: "robust", "HC", "HC0", "HC1", "HC2", "HC3", "HC4", "HC4m", "HC5", "stata", or "classical" (alias "constant" or "iid").

  • formula or list of formulas with the cluster variable(s) on the right-hand side (e.g., ~clusterid).

  • function or list of functions which return variance-covariance matrices with row and column names equal to the names of your coefficient estimates (e.g., 'stats::vcov', 'sandwich::vcovHC').

  • list of 'length(models)' variance-covariance matrices with row and column names equal to the names of your coefficient estimates.

  • a list of length(models) vectors with names equal to the names of your coefficient estimates. See 'Examples' section below.

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.