我使用了
feols
包中的 fixest
来运行回归,我想测试我的系数是否等于某个值(在我的例子中,等于 1)。我可以使用 linearHypothesis
包中的 car
命令来测试吗?
我尝试过以下方法:
linearHypothesis(reg1[[1]],"m_s = 1")
(其中 reg1 是固定对象的列表)。我没有得到 F 统计量,而是 Chisq 统计量。查看结果:
Linear hypothesis test
Hypothesis:
m_s = 1
Model 1: restricted model
Model 2: f_n_m_t_m - f_n ~ 1 + m_s
Res.Df Df Chisq Pr(>Chisq)
1 255
2 254 1 19.749 8.832e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
这样对吗?
我需要任何帮助。
答案是肯定的,你所做的编码是正确的。
虽然没有
linearHypothesis.fixest
方法,但根据文档,
默认方法适用于任何可以通过
检索系数向量并通过coef
检索系数协方差矩阵的模型对象(否则参数vcov
。必须显式设置)。vcov
可重现的示例:
library(fixest)
library(car)
#> Loading required package: carData
res <- feols(Sepal.Length ~ Sepal.Width + Petal.Length | Species, iris)
class(res)
#> [1] "fixest"
coef(res)
#> Sepal.Width Petal.Length
#> 0.4322172 0.7756295
vcov(res)
#> Sepal.Width Petal.Length
#> Sepal.Width 0.02602035 -0.01390552
#> Petal.Length -0.01390552 0.01601377
创建于 2024 年 10 月 22 日,使用 reprex v2.1.1
coef.fixest
和vcov.fixest
都存在,所以linearHypothesis(res)
应该可以工作。
library(fixest)
library(car)
#> Loading required package: carData
res <- feols(Sepal.Length ~ Sepal.Width + Petal.Length | Species, iris)
linearHypothesis(res, "Sepal.Width = 0")
#>
#> Linear hypothesis test:
#> Sepal.Width = 0
#>
#> Model 1: restricted model
#> Model 2: Sepal.Length ~ Sepal.Width + Petal.Length | Species
#>
#> Res.Df Df Chisq Pr(>Chisq)
#> 1 146
#> 2 145 1 7.1794 0.007374 **
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
创建于 2024 年 10 月 22 日,使用 reprex v2.1.1