Skip to contents

Default method to extracts the coefficients table and its sub-components from an estimation.

Usage

# S3 method for default
coeftable(object, keep, drop, order, ...)

# S3 method for default
se(object, keep, drop, order, ...)

# S3 method for default
tstat(object, keep, drop, order, ...)

# S3 method for default
pvalue(object, keep, drop, order, ...)

# S3 method for matrix
se(object, keep, drop, order, ...)

Arguments

object

The result of an estimation (a fitted model object). Note that this function is made to work with fixest objects so it may not work for the specific model you provide.

keep

Character vector. This element is used to display only a subset of variables. This should be a vector of regular expressions (see base::regex help for more info). Each variable satisfying any of the regular expressions will be kept. This argument is applied post aliasing (see argument dict). Example: you have the variable x1 to x55 and want to display only x1 to x9, then you could use keep = "x[[:digit:]]$". If the first character is an exclamation mark, the effect is reversed (e.g. keep = "!Intercept" means: every variable that does not contain “Intercept” is kept). See details.

drop

Character vector. This element is used if some variables are not to be displayed. This should be a vector of regular expressions (see base::regex help for more info). Each variable satisfying any of the regular expressions will be discarded. This argument is applied post aliasing (see argument dict). Example: you have the variable x1 to x55 and want to display only x1 to x9, then you could use drop = "x[[:digit:]]{2}". If the first character is an exclamation mark, the effect is reversed (e.g. drop = "!Intercept" means: every variable that does not contain “Intercept” is dropped). See details.

order

Character vector. This element is used if the user wants the variables to be ordered in a certain way. This should be a vector of regular expressions (see base::regex help for more info). The variables satisfying the first regular expression will be placed first, then the order follows the sequence of regular expressions. This argument is applied post aliasing (see argument dict). Example: you have the following variables: month1 to month6, then x1 to x5, then year1 to year6. If you want to display first the x's, then the years, then the months you could use: order = c("x", "year"). If the first character is an exclamation mark, the effect is reversed (e.g. order = "!Intercept" means: every variable that does not contain “Intercept” goes first). See details.

...

Other arguments that will be passed to summary.

First the method summary is applied if needed, then the coefficients table is extracted from its output.

The default method is very naive and hopes that the resulting coefficients table contained in the summary of the fitted model is well formed: this assumption is very often wrong. Anyway, there is no development intended since the coeftable/se/pvalue/tstat series of methods is only intended to work well with fixest objects. To extract the coefficients table from fitted models in a general way, it's better to use tidy from broom.

Value

Returns a matrix (coeftable) or vectors.

Functions

  • se(default): Extracts the standard-errors from an estimation

  • tstat(default): Extracts the standard-errors from an estimation

  • pvalue(default): Extracts the p-values from an estimation

  • se(matrix): Extracts the standard-errors from a VCOV matrix

Examples


# NOTA: This function is really made to handle fixest objects
# The default methods works for simple structures, but you'd be
# likely better off with broom::tidy for other models

est = lm(mpg ~ cyl, mtcars)
coeftable(est)
#>             Estimate Std. Error   t value     Pr(>|t|)
#> (Intercept) 37.88458  2.0738436 18.267808 8.369155e-18
#> cyl         -2.87579  0.3224089 -8.919699 6.112687e-10

se(est)
#> (Intercept)         cyl 
#>   2.0738436   0.3224089