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

p-values differ from Stata results, with clustered SEs. #19

Open
sleeubc opened this issue Jul 1, 2019 · 1 comment
Open

p-values differ from Stata results, with clustered SEs. #19

sleeubc opened this issue Jul 1, 2019 · 1 comment

Comments

@sleeubc
Copy link

sleeubc commented Jul 1, 2019

Thank you for writing such a fantastic package. I like felm so much, and I use it instead of lm.

My coauthor found that p-values reported from felm differ from the ones from Stata when standard errors are clustered. This lead to different number of stars in our regression tables. In the example below, the coefficient estimates, SEs, t-values are all same but p-values for x are very different (0.0016 vs. 0.003).

I looked into this issue, and it seems that the degree of freedom used in p-value calculation are different. felm uses n-p where n is the number of observations and p is the number of regressors including constant and dummy variables, while Stata uses G-1 for clustered samples where G is the number of clusters.

You may find a discussion on page 23 of a paper by Cameron and Miller helpful: http://cameron.econ.ucdavis.edu/research/Cameron_Miller_JHR_2015_February.pdf

set.seed(0)
n_cl <- 50
n_obs <- n_cl*10
cl <- rnorm(1:n_cl)
x <- rnorm(n_obs)
eps <- cl + rnorm(n_obs, 0, 10)
y <- x+eps
DF <- data.frame(cl, y, x)
model <- lfe::felm(y ~ x| 0 | 0| cl, data= DF )
summary(model)

#> Coefficients:
#>             Estimate Cluster s.e. t value Pr(>|t|)   
#> (Intercept)  -0.4771       0.3865  -1.234   0.2177   
#> x             1.2233       0.3854   3.174   0.0016 **
#> ---

Stata

. reg y x, vce(cluster cl)
		
	                  Robust
y         Coef.	        Std. Err.      t	P>t     [95% Conf. Interval]	
x          1.223281	.3854183     3.17	0.003     .4487536    1.997808
_cons   -.4771046	.3865388    -1.23	0.223    -1.253883    .2996742
		
@karldw
Copy link
Contributor

karldw commented Jul 4, 2019

Cross-ref with another degrees-of-freedom issue: #1

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

2 participants