【问题标题】:F-test with plm-model使用 plm 模型进行 F 检验
【发布时间】:2010-12-08 23:54:04
【问题描述】:

我想对 plm 模型进行 f 测试并测试

model <- plm(y ~ a + b)

如果

# a = b

# a = 0 and b = 0

我试过这样的线性假设

linearHypothesis(ur.model, c("a", "b")) to test for a = 0 and b = 0

但出现错误

Error in constants(lhs, cnames_symb) : 
  The hypothesis "sgp1" is not well formed: contains bad coefficient/variable names.
Calls: linearHypothesis ... makeHypothesis -> rbind -> Recall -> makeHypothesis -> constants
In addition: Warning message:
In constants(lhs, cnames_symb) : NAs introduced by coercion
Execution halted

如果问题很简单,我上面的示例是稍微简化的代码。如果问题出在细节上,这里就是实际代码。

model3 <- formula(balance.agr ~ sgp1 + sgp2 + cp + eu + election + gdpchange.imf + ue.ameco)
ur.model<-plm(model3, data=panel.l.fullsample, index=c("country","year"), model="within", effect="twoways")
linearHypothesis(ur.model, c("sgp1", "sgp2"), vcov.=vcovHC(plmmodel1, method="arellano", type = "HC1", clustering="group"))

【问题讨论】:

  • 如果您提供自己的代码,请确保我们有一个数据集可供试用。下次请提供可重现的示例。

标签: r plm


【解决方案1】:

即使经过相当多的摆弄,我也无法使用其中一个内置数据集重现您的错误。

这对你有用吗?

require(plm)
require(car)
data(Grunfeld)
form <- formula(inv ~ value + capital)
re <- plm(form, data = Grunfeld, model = "within", effect = "twoways")
linearHypothesis(re, c("value", "capital"), 
                 vcov. = vcovHC(re, method="arellano", type = "HC1"))

另请注意,您显示的更复杂的代码似乎有错误。您在对象ur.model 上使用linearHypothesis(),但在对象plmmodel1 上调用vcovHC()。不确定这是否是问题,但请检查以防万一。

可以提供数据吗?最后,编辑您的问题以包含来自sessionInfo() 的输出。我的是(来自一个非常繁忙的 R 实例):

> sessionInfo()
R version 2.11.1 Patched (2010-08-25 r52803)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
 [5] LC_MONETARY=C             LC_MESSAGES=en_GB.utf8   
 [7] LC_PAPER=en_GB.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] splines   grid      stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] car_2.0-2        nnet_7.3-1       plm_1.2-6        Formula_1.0-0   
 [5] kinship_1.1.0-23 lattice_0.19-11  nlme_3.1-96      survival_2.35-8 
 [9] mgcv_1.6-2       chron_2.3-37     MASS_7.3-7       vegan_1.17-4    
[13] lmtest_0.9-27    sandwich_2.2-6   zoo_1.6-4        moments_0.11    
[17] ggplot2_0.8.8    proto_0.3-8      reshape_0.8.3    plyr_1.2.1      

loaded via a namespace (and not attached):
[1] Matrix_0.999375-44 tools_2.11.1

【讨论】:

    【解决方案2】:

    可能是因为您正在“混合”模型吗?您有一个开始的方差规范:

    , ...vcov.=vcovHC(plmmodel1, 
    

    ...但您正在使用ur.model

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 2012-03-02
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      相关资源
      最近更新 更多