2014-01-26 31 views
0

警告信息,我有一个问题,运行此PLM模型:PLM模式 “内” - R中

我的数据(例如):

country=c(1,1,1,2,2,2,3,3,3) 
    year=c(1,2,3,1,2,3,1,2,3) 
    a=c(1,4,6,3,5,8,4,5,7) 
    b=c(8,5,7,2,7,4,9,7,1) 
    matrix=cbind(country, year, a, b) 
    matrix=plm.data(matrix) 

我运行如下回归方程:

reg=plm(a~year+b, data=matrix, index=NULL, model="within") 
    summary(reg) 

,并获得以下警告信息:[1]

Warning messages: 
    1: In if (is.na(le)) { : 
     the condition has length > 1 and only the first element will be used 
    2: In if (is.na(le)) " __no length(.)__ " else if (give.length) { : 
     the condition has length > 1 and only the first element will be used 
    3: In if (le > 0) paste0("[1:", paste(le), "]") else "(0)" : 
     the condition has length > 1 and only the first element will be used 

有什么不对?

+0

该代码在pkg:plm版本1.4-0中用'plm.data'引出错误。 –

+0

@ user3237581:你发现了更多关于这个错误的信息吗?我对此非常感兴趣。 – majom

回答

1

我有同样的问题,并找到了答案(here

当这样的载体给出这样的警告:

le<-c(4,2,6,5) 

在试验中使用这样的:

if(is.na(le)) ... 

R仅查看测试向量中的第一个值,但会警告您有其他未经测试的值。如果测试:

if(is.na(le[1])) 

这并不重要,如果“了”只有一个值或一个以上的,你 没有得到警告。它通常不会弄乱任何东西。

1

这是因为str检查其对象的长度,plm使用来自Formula包的扩展公式。现在,Formula:::length.Formula返回一个向量,而不是一个数字,这会导致警告,正如simon_icl所解释的那样。虽然你自己可能不会调用str,但是也许你的IDE,比如RStudio,可能会用它来显示工作区中对象的对象结构。