Utility to extract the coefficients of multiple estimations and rearrange them into a matrix.
## S3 method for class 'fixest_multi'coef( object, keep, drop, order, collin =FALSE, long =FALSE, na.rm =TRUE,...)## S3 method for class 'fixest_multi'coefficients( object, keep, drop, order, collin =FALSE, long =FALSE, na.rm =TRUE,...)
Arguments
object: A fixest_multi object. Obtained from a multiple estimation.
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.
long: Logical, default is FALSE. Whether the results should be displayed in a long format.
na.rm: Logical, default is TRUE. Only applies when long = TRUE: whether to remove the coefficients with NA values.
...: Not currently used.
Examples
base = iris
names(base)= c("y","x1","x2","x3","species")# A multiple estimationest = feols(y ~ x1 + csw0(x2, x3), base)# Getting all the coefficients at once,# each row is a modelcoef(est)# Example of keep/drop/ordercoef(est, keep ="Int|x1", order ="x1")# To change the order of the model, use fixest_multi# extraction tools:coef(est[rhs = .N:1])# collin + long + na.rmbase$x1_bis = base$x1 # => collinearest = feols(y ~ x1_bis + csw0(x1, x2, x3), base, split =~species)# does not display x1 since it is always collinearcoef(est)# now it doescoef(est, collin =TRUE)# longcoef(est, long =TRUE)# long but balanced (with NAs then)coef(est, long =TRUE, na.rm =FALSE)