The indices of the dropped observations are stored in m$fixef_removed
, so if you pass data[-m$fixef_removed$id,]
as the data
argument in your second call, you will be running the two regressions on the same observations.
Here's a minimal example:
library(fixest)
# Sample data - note id 2 only has one observation
data <- data.frame(id = c(1, 1, 1, 2, 3, 3, 3, 4, 4, 4),
x = c(1, 2, 3, 2, 1, 2, 3, 1, 2, 3),
y = c(1, 3, 2, 0, 5, 2, 6, 6, 13, 7))
m <- fepois(y ~ x | id, data)
#> NOTE: 1 fixed-effect (1 observation) removed because of only 0 outcomes.
n <- fepois(y ~ x, data[-m$fixef_removed$id,])
We can see both models have the same number of observations:
summary(m)
#> Poisson estimation, Dep. Var.: y
#> Observations: 9
#> Fixed-effects: id: 3
#> Standard-errors: Clustered (id)
#> Estimate Std. Error t value Pr(>|t|)
#> x 0.100167 0.04197 2.38664 0.017003 *
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Log-Likelihood: -17.7 Adj. Pseudo R2: 0.165207
#> BIC: 44.2 Squared Cor.: 0.642757
summary(n)
#> Poisson estimation, Dep. Var.: y
#> Observations: 9
#> Standard-errors: IID
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 1.321910 0.450951 2.931385 0.0033745 **
#> x 0.107349 0.202613 0.529822 0.5962356
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Log-Likelihood: -27.6 Adj. Pseudo R2: -0.030282
#> BIC: 59.5 Squared Cor.: 0.011293
Created on 2022-08-11 by the reprex package (v2.0.1)