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 fixest
summary(
  object,
  se = NULL,
  cluster = NULL,
  dof = NULL,
  .vcov,
  stage = 2,
  lean = FALSE,
  agg = NULL,
  forceCovariance = FALSE,
  keepBounded = FALSE,
  n,
  nthreads = getFixest_nthreads(),
  ...
)

summ(
  object,
  se,
  cluster,
  dof = getFixest_dof(),
  forceCovariance = FALSE,
  keepBounded = FALSE,
  ...
)

# S3 method for fixest_list
summary(
  object,
  se,
  cluster,
  dof = getFixest_dof(),
  .vcov,
  stage = 2,
  lean = FALSE,
  n,
  ...
)

Arguments

object

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

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: se = "cluster", otherwise se = "standard". Note that this argument can be implicitly deduced from the argument cluster.

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 var1 and var2 contained in the data.frame base used for the estimation. All the following cluster arguments are valid and do the same thing: cluster = base[, c("var1", "var2")], cluster = c("var1", "var2"), cluster = ~var1+var2. If the two variables were used as clusters in the estimation, you could further use cluster = 1:2 or leave it blank with se = "twoway" (assuming var1 [resp. var2] was the 1st [res. 2nd] cluster). You can interact two variables using ^ with the following syntax: cluster = ~var1^var2 or cluster = "var1^var2".

dof

An object of class dof.type obtained with the function dof. Represents how the degree of freedom correction should be done.You must use the function dof for this argument. The arguments and defaults of the function dof are: adj = TRUE, fixef.K="nested", cluster.adj = TRUE, cluster.df = "conventional", t.df = "conventional", fixef.force_exact=FALSE). See the help of the function dof for details.

.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 2 (default), 1, 1:2 or 2:1. Only used if the object is an IV estimation: defines the stage to which summary should be applied. If stage = 1 and there are multiple endogenous regressors or if stage is of length 2, then an object of class fixest_multi is returned.

lean

Logical, default is FALSE. Used to reduce the (memory) size of the summary object. If TRUE, then all objects of length N (the number of observations) are removed from the result. Note that some fixest methods may consequently not work when applied to the summary.

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 "(root)", the parentheses must be there and the resulting variable name will be "root". You can add another root with parentheses: "(root1)regex(root2)", in which case the resulting name is "root1::root2". To name the resulting variable differently you can pass a named vector: c("name" = "pattern") or c("name" = "pattern(root2)"). It's a bit intricate sorry, please see the examples.

forceCovariance

(Advanced users.) Logical, default is FALSE. In the peculiar case where the obtained Hessian is not invertible (usually because of collinearity of some variables), use this option to force the covariance matrix, by using a generalized inverse of the Hessian. This can be useful to spot where possible problems come from.

keepBounded

(Advanced users -- feNmlm with non-linear part and bounded coefficients only.) Logical, default is FALSE. If TRUE, then the bounded coefficients (if any) are treated as unrestricted coefficients and their S.E. is computed (otherwise it is not).

n

Integer, default is missing (means Inf). 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 setFixest_nthreads.

...

Only used if the argument .vocv is provided and is a function: extra arguments to be passed to that function.

Value

It returns a fixest object with:

cov.scaled

The new variance-covariance matrix (computed according to the argument se).

se

The new standard-errors (computed according to the argument se).

coeftable

The table of coefficients with the new standard errors.

Compatibility with sandwich package

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).

See also

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.

Author

Laurent Berge

Examples

# 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)
#> sum_standard sum_hetero sum_oneway #> Dependent Var.: Euros Euros Euros #> #> log(dist_km) -1.528*** (1.93e-6) -1.528*** (0.0220) -1.528*** (0.1156) #> Fixed-Effects: ------------------- ------------------ ------------------ #> Country of Origin Yes Yes Yes #> Destination Yes Yes Yes #> Product Yes Yes Yes #> _________________ ___________________ __________________ __________________ #> S.E. type Standard Heteroskedas.-rob. by: Origin #> Observations 38,325 38,325 38,325 #> Squared Cor. 0.60377 0.60377 0.60377 #> Pseudo R2 0.76039 0.76039 0.76039 #> BIC 1.43e+12 1.43e+12 1.43e+12 #> sum_twoway sum_threeway #> Dependent Var.: Euros Euros #> #> log(dist_km) -1.528*** (0.1307) -1.528*** (0.1340) #> Fixed-Effects: ------------------ ------------------ #> Country of Origin Yes Yes #> Destination Yes Yes #> Product Yes Yes #> _________________ __________________ __________________ #> S.E. type by: Orig. & Dest. by: Orig. & Dest.. #> Observations 38,325 38,325 #> Squared Cor. 0.60377 0.60377 #> Pseudo R2 0.76039 0.76039 #> BIC 1.43e+12 1.43e+12
# 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"))
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Two-way (Destination & Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.119263 -12.81 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
summary(est_pois, cluster = trade[, c("Destination", "Product")])
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Two-way (Destination & Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.119263 -12.81 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
summary(est_pois, cluster = list(trade$Destination, trade$Product))
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Two-way #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.119263 -12.81 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
summary(est_pois, cluster = ~Destination+Product)
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Two-way (Destination & Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.119263 -12.81 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
# Since Destination and Product are used as fixed-effects, you can also use: summary(est_pois, cluster = 2:3)
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Two-way (Destination & Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.119263 -12.81 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
# You can interact the clustering variables "live" using the var1 ^ var2 syntax. summary(est_pois, cluster = "Destination^Product")
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Clustered (Destination^Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.072633 -21.034 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
summary(est_pois, cluster = ~Destination^Product)
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Clustered (Destination^Product) #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.072633 -21.034 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
# Equivalent to summary(est_pois, cluster = paste(trade$Destination, trade$Product))
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: Clustered #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.072633 -21.034 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377
# # 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")])
#> Poisson estimation, Dep. Var.: Euros #> Observations: 38,325 #> Fixed-effects: Origin: 15, Destination: 15, Product: 20 #> Standard-errors: vcovCL #> Estimate Std. Error z value Pr(>|z|) #> log(dist_km) -1.5277 0.120014 -12.73 < 2.2e-16 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> Log-Likelihood: -7.133e+11 Adj. Pseudo R2: 0.760389 #> BIC: 1.427e+12 Squared Cor.: 0.60377