This function sets globally the default arguments of fixest estimations.
setFixest_estimation(
data = NULL,
panel.id = NULL,
fixef.rm = "perfect_fit",
fixef.tol = 1e-06,
fixef.iter = 10000,
collin.tol = 1e-10,
lean = FALSE,
verbose = 0,
warn = TRUE,
fixef.keep_names = NULL,
demeaned = FALSE,
mem.clean = FALSE,
glm.iter = 25,
glm.tol = 1e-08,
data.save = FALSE,
reset = FALSE
)
getFixest_estimation()A data.frame containing the necessary variables to run the model.
The variables of the non-linear right hand side of the formula are identified
with this data.frame names. Can also be a matrix.
The panel identifiers. Can either be: i) a one sided formula
(e.g. panel.id = ~id+time), ii) a character vector of length 2
(e.g. panel.id=c('id', 'time'), or iii) a character scalar of two variables
separated by a comma (e.g. panel.id='id,time'). Note that you can combine variables
with ^ only inside formulas (see the dedicated section in feols).
Can be equal to "perfect_fit" (default), "singletons", "infinite_coef" or "none".
This option controls which observations should be removed prior to the estimation. If "singletons", fixed-effects associated to a single observation are removed (since they perfectly explain it).
The value "infinite_coef" only works with GLM families with limited left hand sides (LHS)
and exponential link.
For instance the Poisson family for which the LHS cannot be lower than 0, or the logit
family for which the LHS lies within 0 and 1.
In that case the fixed-effects (FEs) with only-0 LHS would lead to infinite coefficients
(FE = -Inf would explain perfectly the LHS).
The value fixef.rm="infinite_coef" removes all observations associated to FEs with
infinite coefficients.
If "perfect_fit", it is equivalent to "singletons" and "infinite_coef" combined. That means all observations that are perfectly explained by the FEs are removed.
If "none": no observation is removed.
Note that whathever the value of this options: the coefficient estimates will remain the same. It only affects inference (the standard-errors).
The algorithm is recursive, meaning that, e.g. in the presence of several fixed-effects (FEs), removing singletons in one FE can create singletons (or perfect fits) in another FE. The algorithm continues until there is no singleton/perfect-fit remaining.
Precision used to obtain the fixed-effects. Defaults to 1e-5.
It corresponds to the maximum absolute difference allowed between two coefficients
of successive iterations. Argument fixef.tol cannot be lower
than 10000*.Machine$double.eps. Note that this parameter is dynamically
controlled by the algorithm.
Maximum number of iterations in fixed-effects algorithm (only in use for 2+ fixed-effects). Default is 10000.
Numeric scalar, default is 1e-9. Threshold deciding when variables should
be considered collinear and subsequently removed from the estimation. Higher values means more
variables will be removed (if there is presence of collinearity). One signal of presence of
collinearity is t-stats that are extremely low (for instance when t-stats < 1e-3).
Logical scalar, default is FALSE. If TRUE then all large objects are removed
from the returned result: this will save memory but will block the possibility to
use many methods. It is recommended to use the arguments se or cluster to
obtain the appropriate standard-errors at estimation time, since obtaining different
SEs won't be possible afterwards.
Integer. Higher values give more information. In particular, it can detail the number of iterations in the demeaning algorithm (the first number is the left-hand-side, the other numbers are the right-hand-side variables).
Logical, default is TRUE. Whether warnings should be displayed
(concerns warnings relating to convergence state).
Logical or NULL (default). When you combine different
variables to transform them into a single fixed-effects you can do
e.g. y ~ x | paste(var1, var2).
The algorithm provides a shorthand to do the same operation: y ~ x | var1^var2.
Because pasting variables is a costly operation, the internal algorithm may use a
numerical trick to hasten the process. The cost of doing so is that you lose the labels.
If you are interested in getting the value of the fixed-effects coefficients
after the estimation, you should use fixef.keep_names = TRUE. By default it is
equal to TRUE if the number of unique values is lower than 50,000, and to FALSE
otherwise.
Logical, default is FALSE. Only used in the presence of fixed-effects: should
the centered variables be returned? If TRUE, it creates the items
y_demeaned and X_demeaned.
Logical scalar, default is FALSE. Only to be used if the data set is
large compared to the available RAM. If TRUE then intermediary objects are removed as
much as possible and gc is run before each substantial C++ section in the internal
code to avoid memory issues.
Number of iterations of the glm algorithm. Default is 25.
Tolerance level for the glm algorithm. Default is 1e-8.
Logical scalar, default is FALSE. If TRUE, the data used for
the estimation is saved within the returned object. Hence later calls to predict(),
vcov(), etc..., will be consistent even if the original data has been modified
in the meantime.
This is especially useful for estimations within loops, where the data changes
at each iteration, such that postprocessing can be done outside the loop without issue.
Logical scalar, default is FALSE. Whether to reset all values.
The function getFixest_estimation returns the currently set global defaults.
#
# Example: removing singletons is FALSE by default
#
# => changing this default
# Let's create data with singletons
base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
base$fe_singletons = as.character(base$species)
base$fe_singletons[1:5] = letters[1:5]
res = feols(y ~ x1 + x2 | fe_singletons, base)
#> NOTE: 5 fixed-effect singletons were removed (5 observations).
res_noSingle = feols(y ~ x1 + x2 | fe_singletons, base, fixef.rm = "single")
#> NOTE: 5 fixed-effect singletons were removed (5 observations).
# New defaults
setFixest_estimation(fixef.rm = "single")
res_newDefault = feols(y ~ x1 + x2 | fe_singletons, base)
#> NOTE: 5 fixed-effect singletons were removed (5 observations).
etable(res, res_noSingle, res_newDefault)
#> res res_noSingle res_newDefault
#> Dependent Var.: y y y
#>
#> x1 0.4274*** (0.0835) 0.4274*** (0.0835) 0.4274*** (0.0835)
#> x2 0.7774*** (0.0652) 0.7774*** (0.0652) 0.7774*** (0.0652)
#> Fixed-Effects: ------------------ ------------------ ------------------
#> fe_singletons Yes Yes Yes
#> _______________ __________________ __________________ __________________
#> S.E. type IID IID IID
#> Observations 145 145 145
#> R2 0.85729 0.85729 0.85729
#> Within R2 0.64201 0.64201 0.64201
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Resetting the defaults
setFixest_estimation(reset = TRUE)