R: Finds observations to be removed from ML estimation with...

obs2remove {fixest} | R Documentation

## Finds observations to be removed from ML estimation with fixed-effects

### Description

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.

### Usage

    obs2remove(fml, data, family = c("poisson", "negbin", "logit"))

### Arguments

`fml` | A formula containing the dependent variable and the fixed-effects. It can be of the type: `y ~ fixef_1 + fixef_2` or `y ~ x1 | fixef_1 + fixef_1` (in which case variables before the pipe are ignored).
`data` | A data.frame containing the variables in the formula.
`family` | Character scalar: either “poisson” (default), “negbin” or “logit”.

### Value

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.

### See Also

`fixest-deprecated`

### Examples

    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$obsRemoved == x)

[Package fixest version 0.8.4 Index]