我正在尝试从具有许多因素的线性模型中获取拟合值,我希望使用R包中的函数进行估计。除非我误解了函数返回的的含义,否则看起来这些值与手动构建的输出不匹配。这是一个从软件包文档中调整的示例:
library(lfe)
set.seed(42)
nn = 10
n1 = 3
x <- rnorm(nn)
f1 <- sample(n1, length(x), replace=TRUE)
y <- 2.13*x + cos(f1) + rnorm(length(x), sd=0.5)
est <- felm(y ~ x | f1)
estb <- lm(y~x+factor(f1)-1)
# we have exactly the same coefficients
getfe(est)['effect']/estb$coefficients[2:(n1+1)]
est$coefficients/estb$coefficients[1]
# but different fitted values -- in fact all having the same group offset
estb$fitted.values-est$fitted.values
这些偏移量是什么?
felm
是否打算返回不同种类的拟合值?谢谢查看。