Code Monkey home page Code Monkey logo

Comments (3)

lrberge avatar lrberge commented on August 18, 2024

Sure, you have two specific objects in the output:

  • obsRemoved: vector of observations that were removed,
  • fixef_removed: fixed-effect identifiers that were removed because of only 0/1 outcomes (depends on the family).
library(fixest)

base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
base$y[1] = NA
base$y[base$species == "versicolor"] = 0

(res = fepois(y ~ x1 + x2 | species, base))
#> NOTES: 1 observation removed because of NA values (Breakup: LHS: 1, RHS: 0, Fixed-effects: 0).
#>        1 fixed-effect (50 observations) removed because of only zero outcomes.
#> Poisson estimation, Dep. Var.: y
#> Observations: 99 
#> Fixed-effects: species: 2
#> Standard-errors: Clustered (species) 
#>    Estimate Std. Error z value   Pr(>|z|)    
#> x1 0.089710   0.045578  1.9683 4.9034e-02 *  
#> x2 0.124233   0.017720  7.0109 2.3700e-12 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Log-likelihood: -179.54   Adj. Pseudo-R2: 0.02014 
#>            BIC:  377.47     Squared Cor.: 0.90493

# Vector of observation IDs removed
head(res$obsRemoved)
#> [1]  1 51 52 53 54 55

# Fixed-effects removed because of only 0 outcomes
res$fixef_removed
#> $species
#> [1] "versicolor"

from fixest.

yceny avatar yceny commented on August 18, 2024

I got the fixef_removed part. How shall I remove data based on obsRemoved? In my case, it looks like this

> head(res$obsRemoved)
NA NA.1 NA.2 5 NA.3
1 2 3 4 5 6

All the number seems consecutive. And shall I also create a variable like ID in my original data to remove those?

from fixest.

lrberge avatar lrberge commented on August 18, 2024

I don't really understand. Maybe the first observations contain NA somewhere?

For me it works as expected:

> base = iris
> names(base) = c("y", "x1", "x2", "x3", "species")
> 
> base$y[1] = NA
> base$x1[3] = NA
> base$x2[5] = NA
> base$species[15:17] = NA
> 
> est = feols(y ~ x1 + x2 | species, base)
#> NOTE: 6 observations removed because of NA values (Breakup: LHS: 1, RHS: 2, Fixed-effects: 3).
> 
> est$obsRemoved
#> [1]  1  3  5 15 16 17

from fixest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.