We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I get different results when comparing the value of the intercept calculated by the function lm, with that obtained with the function lfe::getfe.
Here's a reproducible example:
` library(lfe)
set.seed(123)
x <- rnorm(4000) x2 <- rnorm(length(x))
id <- factor(sample(500,length(x),replace=TRUE)) firm <- factor(sample(300,length(x),replace=TRUE))
id.eff <- rlnorm(nlevels(id)) firm.eff <- rexp(nlevels(firm)) y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
est <- felm(y ~ x + x2 | id + firm) est2 <- lm(y ~ x + x2 + id + firm)
coef(est)
coef(est2)[2:3]
fe_est <- getfe(est, ef = "zm2")
fe_est[grepl("icpt", rownames(fe_est)), ]
coef(est2)[1]
`
I am wondering if it is possible to obtain a reliable approximation of the value of the intercept estimated by lm using lfe::getfe.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I get different results when comparing the value of the intercept calculated by the function lm, with that obtained with the function lfe::getfe.
Here's a reproducible example:
`
library(lfe)
set seed for reproducible example
set.seed(123)
generate independent variables
x <- rnorm(4000)
x2 <- rnorm(length(x))
create individual and firm ids
id <- factor(sample(500,length(x),replace=TRUE))
firm <- factor(sample(300,length(x),replace=TRUE))
generate dependent variable
id.eff <- rlnorm(nlevels(id))
firm.eff <- rexp(nlevels(firm))
y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
estimate results
est <- felm(y ~ x + x2 | id + firm)
est2 <- lm(y ~ x + x2 + id + firm)
Compare estimates
coef(est)
x x2
1.017696 0.246784
coef(est2)[2:3]
x x2
1.017696 0.246784
estimate fixed effects
fe_est <- getfe(est, ef = "zm2")
Compare intercept
fe_est[grepl("icpt", rownames(fe_est)), ]
effect obs comp
icpt.1 2.583704 4000 1
coef(est2)[1]
(Intercept)
7.312307
`
I am wondering if it is possible to obtain a reliable approximation of the value of the intercept estimated by lm using lfe::getfe.
The text was updated successfully, but these errors were encountered: