Skip to contents

This function extracts the coefficients obtained from a model estimated with femlm, feols or feglm.

Usage

# S3 method for fixest
coef(object, keep, drop, order, collin = FALSE, agg = TRUE, ...)

# S3 method for fixest
coefficients(object, keep, drop, order, collin = FALSE, agg = TRUE, ...)

Arguments

object

A fixest object. Obtained using the functions femlm, feols or feglm.

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.

collin

Logical, default is FALSE. Whether the coefficients removed because of collinearity should be also returned as NA. It cannot be used when coefficients aggregation is also used.

agg

Logical scalar, default is TRUE. If the coefficients of the estimation have been aggregated, whether to report the aggregated coefficients. If FALSE, the raw coefficients will be returned.

...

Not currently used.

Value

This function returns a named numeric vector.

Details

The coefficients are the ones that have been found to maximize the log-likelihood of the specified model. More information can be found on the models from the estimations help pages: femlm, feols or feglm.

Note that if the model has been estimated with fixed-effects, to obtain the fixed-effect coefficients, you need to use the function fixef.fixest.

See also

See also the main estimation functions femlm, feols or feglm. summary.fixest, confint.fixest, vcov.fixest, etable, fixef.fixest.

Author

Laurent Berge

Examples


# simple estimation on iris data, using "Species" fixed-effects
res = femlm(Sepal.Length ~ Sepal.Width + Petal.Length +
            Petal.Width | Species, iris)

# the coefficients of the variables:
coef(res)
#>  Sepal.Width Petal.Length  Petal.Width 
#>   0.08866057   0.12992811  -0.04957634 

# the fixed-effects coefficients:
fixef(res)
#> $Species
#>     setosa versicolor  virginica 
#>  1.1280816  1.0451815  0.9973101 
#> 
#> attr(,"class")
#> [1] "fixest.fixef" "list"        
#> attr(,"exponential")
#> [1] TRUE