| summary.fixest {fixest} | R Documentation |
fixest object. Computes different types of standard errors.This function is similar to print.fixest. It provides the table of coefficients along with other information on the fit of the estimation. It can compute different types of standard errors. The new variance covariance matrix is an object returned.
## S3 method for class 'fixest' summary( object, se = NULL, cluster = NULL, dof = NULL, .vcov, stage = 2, lean = FALSE, agg = NULL, forceCovariance = FALSE, keepBounded = FALSE, n = 1000, nthreads = getFixest_nthreads(), ... ) ## S3 method for class 'fixest_list' summary( object, se, cluster, dof = getFixest_dof(), .vcov, stage = 2, lean = FALSE, n, ... )
object |
A |
se |
Character scalar. Which kind of standard error should be computed: “standard”, “hetero”, “cluster”, “twoway”, “threeway” or “fourway”? By default if there are clusters in the estimation: |
cluster |
Tells how to cluster the standard-errors (if clustering is requested). Can be either a list of vectors, a character vector of variable names, a formula or an integer vector. Assume we want to perform 2-way clustering over |
dof |
An object of class |
.vcov |
A user provided covariance matrix or a function computing this matrix. If a matrix, it must be a square matrix of the same number of rows as the number of variables estimated. If a function, it must return the previously mentioned matrix. |
stage |
Can be equal to |
lean |
Logical, default is |
agg |
A character scalar describing the variable names to be aggregated, it is pattern-based. All variables that match the pattern will be aggregated. It must be of the form |
forceCovariance |
(Advanced users.) Logical, default is |
keepBounded |
(Advanced users – |
n |
Integer, default is 1000. Number of coefficients to display when the print method is used. |
nthreads |
The number of threads. Can be: a) an integer lower than, or equal to, the maximum number of threads; b) 0: meaning all available threads will be used; c) a number strictly between 0 and 1 which represents the fraction of all threads to use. The default is to use 50% of all threads. You can set permanently the number of threads used within this package using the function |
... |
Only used if the argument |
It returns a fixest object with:
cov.scaled |
The new variance-covariance matrix (computed according to the argument |
se |
The new standard-errors (computed according to the argument |
coeftable |
The table of coefficients with the new standard errors. |
The VCOVs from sandwich can be used with feols, feglm and fepois estimations. If you want to have a sandwich VCOV when using summary.fixest, you can use the argument .vcov to specify the VCOV function to use (see examples).
Note that if you do so and you use a formula in the cluster argument, an innocuous warning can pop up if you used several non-numeric fixed-effects in the estimation (this is due to the function expand.model.frame used in sandwich).
Laurent Berge
See also the main estimation functions femlm, feols or feglm. Use fixef.fixest to extract the fixed-effects coefficients, and the function etable to visualize the results of multiple estimations.
# Load trade data
data(trade)
# We estimate the effect of distance on trade (with 3 fixed-effects)
est_pois = fepois(Euros ~ log(dist_km)|Origin+Destination+Product, trade)
# Comparing different types of standard errors
sum_standard = summary(est_pois, se = "standard")
sum_hetero = summary(est_pois, se = "hetero")
sum_oneway = summary(est_pois, se = "cluster")
sum_twoway = summary(est_pois, se = "twoway")
sum_threeway = summary(est_pois, se = "threeway")
etable(sum_standard, sum_hetero, sum_oneway, sum_twoway, sum_threeway)
# Alternative ways to cluster the SE:
# two-way clustering: Destination and Product
# (Note that arg. se = "twoway" is implicitly deduced from the argument cluster)
summary(est_pois, cluster = c("Destination", "Product"))
summary(est_pois, cluster = trade[, c("Destination", "Product")])
summary(est_pois, cluster = list(trade$Destination, trade$Product))
summary(est_pois, cluster = ~Destination+Product)
# Since Destination and Product are used as fixed-effects, you can also use:
summary(est_pois, cluster = 2:3)
# You can interact the clustering variables "live" using the var1 ^ var2 syntax.
summary(est_pois, cluster = "Destination^Product")
summary(est_pois, cluster = ~Destination^Product)
# Equivalent to
summary(est_pois, cluster = paste(trade$Destination, trade$Product))
#
# Compatibility with sandwich
#
# You can use the VOCVs from sandwich by using the argument .vcov:
library(sandwich)
summary(est_pois, .vcov = vcovCL, cluster = trade[, c("Destination", "Product")])