Skip to contents

This is a mostly internal function which could be useful to users who want a unified approach to extract results from a wide variety of models. For some models get_estimates attaches useful attributes to the output. You can access this information by calling the attributes function: attributes(get_estimates(model))

Usage

get_estimates(
  model,
  conf_level = 0.95,
  vcov = NULL,
  shape = NULL,
  coef_rename = FALSE,
  ...
)

Arguments

model

a single model object

conf_level

numeric value between 0 and 1. confidence level to use for confidence intervals. Setting this argument to NULL does not extract confidence intervals, which can be faster for some models.

vcov

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

  • NULL returns the default uncertainty estimates of the model object

  • string, vector, or (named) list of strings. "iid", "classical", and "constant" are aliases for NULL, which returns the model's default uncertainty estimates. The strings "HC", "HC0", "HC1" (alias: "stata"), "HC2", "HC3" (alias: "robust"), "HC4", "HC4m", "HC5", "HAC", "NeweyWest", "Andrews", "panel-corrected", "outer-product", and "weave" use variance-covariance matrices computed using functions from the sandwich package, or equivalent method. The behavior of those functions can (and sometimes must) be altered by passing arguments to sandwich directly from modelsummary through the ellipsis (...), but it is safer to define your own custom functions as described in the next bullet.

  • function or (named) 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, function(x) vcovPC(x, cluster="country")).

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

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

  • a named list of length(models) vectors with names equal to the names of your coefficient estimates. See 'Examples' section below. Warning: since this list of vectors can include arbitrary strings or numbers, modelsummary cannot automatically calculate p values. The stars argument may thus use incorrect significance thresholds when vcov is a list of vectors.

shape

NULL, formula, or string which determines the shape of a table.

  • NULL: Default shape with terms in rows and models in columns.

  • Formula: The left side determines what appears on rows, and the right side determines what appears on columns. The formula can include one or more group identifier(s) to display related terms together, which can be useful for models with multivariate outcomes or grouped coefficients (See examples section below). The group identifier(s) must be column names produced by: get_estimates(model). The group identifier(s) can be combined with the term identifier in a single column by using the colon to represent an interaction. If an incomplete formula is supplied (e.g., ~statistic), modelsummary tries to complete it automatically. Goodness-of-fit statistics are only appended to the bottom of the table when model is on the right hand side of the formula (i.e., columns). Potential shape values include:

    • term + statistic ~ model: default

    • term ~ model + statistic: statistics in separate columns

    • model + statistic ~ term: models in rows and terms in columns

    • term + response + statistic ~ model: term and group id in separate columns

    • term : response + statistic ~ model: term and group id in a single column

    • term ~ response

  • String: "rbind" or "rcollapse" to bind rows of two or more regression tables to create "panels" or "stacks" of regression models.

    • the models argument must be a (potentially named) nested list of models.

    • Unnamed nested list with 2 panels: list(list(model1, model2), list(model3, model4))

    • Named nested list with 2 panels: list("Panel A" = list(model1, model2), "Panel B" = list(model3, model4))

    • Named panels and named models: list("Panel A" = list("(I)" = model1, "(II)" = model2), "Panel B" = list("(I)" = model3, "(II)" = model4))

    • "rbind": Bind the rows of independent regression tables

    • "rcollapse": Bind the rows of regression tables and create a panel at the bottom where we "collapse" goodness-of-fit statistics which are identical across models.

coef_rename

logical, named or unnamed character vector, or function

  • Logical: TRUE renames variables based on the "label" attribute of each column. See the Example section below.

  • Unnamed character vector of length equal to the number of coefficients in the final table, after coef_omit is applied.

  • 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. Ex: c("hp:mpg"="hp X mpg")

  • Function: Accepts a character vector of the model's term names and returns a named vector like the one described above. The modelsummary package supplies a coef_rename() function which can do common cleaning tasks: modelsummary(model, coef_rename = coef_rename)

...

all other arguments are passed through to three functions. See the documentation of these functions for lists of available arguments.

  • parameters::model_parameters extracts parameter estimates. Available arguments depend on model type, but include:

    • standardize, centrality, dispersion, test, ci_method, prior, diagnostic, rope_range, power, cluster, etc.

  • performance::model_performance extracts goodness-of-fit statistics. Available arguments depend on model type, but include:

    • metrics, estimator, etc.

  • kableExtra::kbl or gt::gt draw tables, depending on the value of the output argument.