0

plm-model の f-test を作成してテストしたい

model <- plm(y ~ a + b)

もしも

# a = b

# a = 0 and b = 0

私はこのようにlinearHypothesisを試しました

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"))
4

2 に答える 2

0

モデルを「混合」しているからでしょうか?次のような差異仕様があります。

, ...vcov.=vcovHC(plmmodel1, 

...そして、あなたは で作業していますur.model

于 2010-12-12T01:51:10.843 に答える
0

かなりいじった後でも、組み込みのデータセットの 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"))

また、表示されたより複雑なコードにエラーがあるように見えることにも注意してください。linearHypothesis()objectを使用していますが、 objectur.modelを呼び出しvcovHC()ていますplmmodel1。それが問題かどうかはわかりませんが、場合によっては確認してください。

データ提供は可能ですか?最後に、質問を編集して からの出力を含めます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
于 2010-12-09T07:58:32.610 に答える