Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables with zero weights still count as observations #38

Open
roussanoff opened this issue Nov 13, 2020 · 0 comments
Open

Variables with zero weights still count as observations #38

roussanoff opened this issue Nov 13, 2020 · 0 comments

Comments

@roussanoff
Copy link

roussanoff commented Nov 13, 2020

felm() includes observations with zero weights when calculating the number of observations. This leads to different degrees of freedom and, hence, calculated statistics. Here is an example:

library(lfe)
cars <- mtcars
cars[cars$carb==2,]$carb <- 0 #need to have some weights that are zero
reg_lfe <- felm(mpg~cyl, 
                weights = cars$carb,
                data = cars)
reg_stats <- lm(mpg~cyl, 
                weights = carb,
                data = cars)

nobs(reg_lfe)
nobs(reg_stats)

reg_lfe has 22 observations, and reg_stats has 32. They also have different F-statistics.

I was using felm() and comparing the reported F-stat from the first stage regression to the one computed manually using lm() and linearHypothesis(). I was getting similar, but not identical results. I realized that the reason was that I had a few observations with zero weights, which changed the F-statistic in felm(), so I think it's an important issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant