Finds observations to be removed from ML estimation with fixed-effects
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 fixed-effect value this leads to a perfect fit for that fixed-effect value by setting its associated fixed-effect 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 fixed-effects. 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 fixef
which is a list giving the IDs of the fixed-effects that have been removed, for each fixed-effect 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, "fixef") # 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$obs_selection$obsRemoved == x)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.