Learn R Programming

fixest (version 0.3.1)

dof: Type of degree of freedom in fixest summary

Description

Provides how the degrees of freedom should be calculated in vcov.fixest/summary.fixest.

Usage

dof(fixef = "nested", exact = FALSE, cluster = TRUE)

Arguments

fixef

How to account for the fixed-effects parameters, defaults to "nested". If FALSE or "no", fixed-effects parameters are discarded, meaning the number of parameters is only equal to the number of variables. If TRUE or yes, then the number of parameters is equal to the number of variables plus the number of fixed-effects. Finally, if nested, then the number of parameters is equal to the number of variables an the number of fixed-effects that *are not* nested in the clusters used to cluster the standard-errors.

exact

Logical, default is FALSE. If there are 2 or more fixed-effects, these fixed-effects they can be irregular, meaning they can provide the same information. If so, the "real" number of parameters should be lower than the total number of fixed-effects. If exact = TRUE, then fixef.fixest is first run to determine the exact number of parameters among the fixed-effects. Mostly, panels of the type individual-firm-year require exact = TRUE (but it adds computational costs).

cluster

Logical, default is TRUE. How to make the small sample correction when clustering the standard-errors? If TRUE a G/(G-1) correction is performed with G the number of cluster values.

Value

It returns a dof.type object.

See Also

summary.fixest, vcov.fixest, setFixest_dof

Examples

Run this code
# NOT RUN {
# We create "irregular" FEs
base = data.frame(x = rnorm(10))
base$y = base$x + rnorm(10)
base$fe1 = rep(1:3, c(4, 3, 3))
base$fe2 = rep(1:5, each = 2)

est = feols(y ~ x | fe1 + fe2, base)

# fe1: 3 FEs
# fe2: 5 FEs

#
# Clustered standard-errors: by fe1
#

# Default: fixef = "nested"
#  => adjustment K = 1 + 5 (i.e. x + fe2)
summary(est)
attributes(vcov(est))[c("dof.type", "dof.K")]


# fixef = FALSE
#  => adjustment K = 1 (i.e. only x)
summary(est, dof = dof(fixef=FALSE))
attr(vcov(est, dof = dof(fixef=FALSE)), "dof.K")


# fixef = TRUE
#  => adjustment K = 1 + 3 + 5 - 1 (i.e. x + fe1 + fe2 - 1 restriction)
summary(est, dof = dof(fixef=TRUE))
attr(vcov(est, dof = dof(fixef=TRUE)), "dof.K")


# fixef = TRUE & exact = TRUE
#  => adjustment K = 1 + 3 + 5 - 2 (i.e. x + fe1 + fe2 - 2 restrictions)
summary(est, dof = dof(fixef=TRUE, exact = TRUE))
attr(vcov(est, dof = dof(fixef=TRUE, exact = TRUE)), "dof.K")

# There are two restrictions:
attr(fixef(est), "references")


# }

Run the code above in your browser using DataLab