obs2remove {fixest} | R Documentation |
For Poisson, Negative Binomial or Logit estimations with fixed-effects, when the dependent variable is only equal to 0 (or 1 for Logit) for one cluster value this leads to a perfect fit for that cluster value by setting its associated cluster coefficient to -Inf
. Thus these observations need to be removed before estimation. This function gives the observations to be removed. Note that by default the function femlm
or feglm
drops them before performing the estimation.
obs2remove(fml, data, family = c("poisson", "negbin", "logit"))
fml |
A formula containing the dependent variable and the clusters. It can be of the type: |
data |
A data.frame containing the variables in the formula. |
family |
Character scalar: either “poisson” (default), “negbin” or “logit”. |
It returns an integer vector of observations to be removed. If no observations are to be removed, an empty integer vector is returned. In both cases, it is of class fixest.obs2remove
.
The vector has an attribute cluster
which is a list giving the IDs of the clusters that have been removed, for each cluster dimension.
base = iris # v6: Petal.Length with only 0 values for 'setosa' base$v6 = base$Petal.Length base$v6[base$Species == "setosa"] = 0 (x = obs2remove(v6 ~ Species, base)) attr(x, "cluster") # The two results are identical: res_1 = femlm(v6 ~ Petal.Width | Species, base) # => note + obsRemoved is created res_2 = femlm(v6 ~ Petal.Width | Species, base[-x, ]) # => no note because observations are removed before esttable(res_1, res_2) all(res_1$obsRemoved == x)