R:terms.default(公式)中的错误:没有术语组件也没有属性(pgmm函数)

J.M*_*tin 5 r panel-data plm

我尝试学习如何将 GMM 方法与 R(Arellano-Bond 估计器)结合使用。所以我使用pgmm包中的命令plm

我复制了此示例的代码:https ://www.rdocumentation.org/packages/plm/versions/1.6-5/topics/pgmm

有了这些数据:

Date        country       credit    a   b   c   d   e   f   g    h  i   j   

2000-01-01  Germany     3840,304    0   0   0   0   0   0   1   .b  0   -1
2000-04-01  Germany     3891,104    0   0   0   0   0   0   0   .b  0   0
2000-07-01  Germany     3916,966    0   0   0   0   0   0   0   .b  0   0
2000-10-01  Germany     3984,611    0   0   0   0   0   0   0   .b  0   0
2001-01-01  Germany     4003,066    0   0   0   0   0   0   0   .b  0   0
2001-04-01  Germany     4012,048    0   0   0   0   0   0   0   .b  0   0
2001-07-01  Germany     4053,672    0   0   0   0   0   0   0   .b  0   0
2001-10-01  Germany     4097,941    0   0   0   0   0   0   0   .b  0   0
2002-01-01  Germany     4108,002    0   0   0   0   0   0   0   .b  0   0
2002-04-01  Germany     4142,119    0   0   0   0   0   0   0   .b  0   0
2002-07-01  Germany     4210,727    0   0   0   0   0   0   0   .b  0   0
2002-10-01  Germany     4220,897    0   0   0   0   0   0   0   .b  0   0
2003-01-01  Germany     4280,548    0   0   0   0   0   0   0   .b  0   0
2003-04-01  Germany     4331,072    0   0   0   0   0   0   0   .b  0   0
2003-07-01  Germany     4322,555    0   0   0   0   0   0   0   .b  0   0
2003-10-01  Germany     4338,01     0   0   0   0   0   0   0   .b  0   0
2004-01-01  Germany     4370,032    0   0   0   0   0   0   0   .b  0   0
2004-04-01  Germany     4354,935    0   0   0   0   0   0   0   .b  0   0
2004-07-01  Germany     4375,466    0   0   0   0   0   0   0   .b  0   0
2004-10-01  Germany     4390,958    0   0   0   0   0   0   0   .b  0   0
2005-01-01  Germany     4396,222    0   0   0   0   0   0   0   .b  0   0
2005-04-01  Germany     4448,471    0   0   0   0   0   0   0   .b  0   0
2005-07-01  Germany     4471,893    0   0   0   0   0   0   0   .b  0   0
2005-10-01  Germany     4451,653    0   0   0   0   0   0   0   .b  0   0
2006-01-01  Germany     4477,181    0   0   0   0   0   0   0   .b  0   0
2006-04-01  Germany     4497,384    0   0   0   0   0   0   0   .b  0   0
2006-07-01  Germany     4545,383    0   0   0   0   0   0   0   .b  0   0
2006-10-01  Germany     4527,901    0   0   0   0   0   0   0   .b  0   0
2007-01-01  Germany     4523,691    0   0   0   0   0   0   1   .b  0   0
2007-04-01  Germany     4514,656    0   0   0   0   0   0   0   .b  0   0
2007-07-01  Germany     4510,95     0   0   0   0   0   0   0   .b  0   0
2007-10-01  Germany     4552,084    0   0   0   0   0   0   0   .b  0   0
2008-01-01  Germany     4577,551    0   0   0   0   0   0   0   .b  0   0
2008-04-01  Germany     4590,665    0   0   0   0   0   0   0   .b  0   0
2008-07-01  Germany     4619,162    0   0   0   0   0   0   0   .b  0   0
2008-10-01  Germany     4719,901    0   0   0   0   0   0   0   .b  0   0
2009-01-01  Germany     4747,204    0   0   0   0   0   0   0   .b  0   0
2009-04-01  Germany     4788,791    0   0   0   0   0   0   0   .b  0   0
2009-07-01  Germany     4794,392    0   0   0   0   0   0   0   .b  0   0
2009-10-01  Germany     4803,617    0   0   0   0   0   0   0   .b  0   0
2010-01-01  Germany     4832,948    0   0   0   0   0   0   0   .b  0   0
2010-04-01  Germany     4925,639    0   0   0   0   0   0   0   .b  0   0
2010-07-01  Germany     4971,252    0   0   0   0   0   0   0   .b  0   0
2010-10-01  Germany     5122,327    0   0   0   0   0   0   0   .b  0   0
2011-01-01  Germany     5041,913    0   0   0   0   0   0   1   .b  0   0
2011-04-01  Germany     5079,78     0   0   0   0   0   0   0   .b  0   0
2011-07-01  Germany     5207,961    0   0   0   0   0   0   0   .b  0   0
2011-10-01  Germany     5231,821    0   0   0   0   0   0   0   .b  0   0
2012-01-01  Germany     5280,251    0   0   0   0   1   0   0   .b  0   -1
2012-04-01  Germany     5392,063    0   0   0   0   0   0   0   .b  0   0
2012-07-01  Germany     5400,905    0   0   0   0   0   0   0   .b  0   0
2012-10-01  Germany     5412,811    0   0   0   0   0   0   0   .b  0   0
2013-01-01  Germany     5422,592    0   0   0   0   0   0   0   .b  0   0
2013-04-01  Germany     5430,467    0   0   0   0   0   0   0   .b  0   0
2013-07-01  Germany     5398,361    0   0   0   0   0   0   0   .b  0   0
2013-10-01  Germany     5432,462    0   0   0   0   0   0   0   .b  0   0
2014-01-01  Germany     5456,415    0   0   0   0   1   0   1   .b  0   0
2014-04-01  Germany     5504,142    0   0   0   0   0   0   0   .b  0   0
2014-07-01  Germany     5516,876    0   0   0   0   0   0   0   .b  0   0
2014-10-01  Germany     5532,75     0   0   0   0   0   0   0   .b  0   0
Run Code Online (Sandbox Code Playgroud)

因变量是“信用”,a、b、c...是自变量。后者是宏观审慎政策和货币政策。因此,我试图了解这些政策(加上滞后因变量)对信贷增长的影响。

对于这些政策,收紧时该指数取值为 1,没有变化时为 0,宽松时为 -1。

我尝试了几次,但总是出现相同的错误: Terms.default(formula) 中的错误:没有术语组件或属性

一些尝试:

test <- pgmm(credit) ~ lag(credit)+lag(a)+lag(b), data = BDD)


pgmm(credit ~ lag((credit), 1) + lag((sscb_res), 1), data = BDD, effect = "twoways", model = "twosteps")
pgmm(credit ~ lag((credit), 0:1) + lag((sscb_res), 0:1), data = BDD, effect = "twoways", model = "twosteps")
Run Code Online (Sandbox Code Playgroud)

等等。我不知道该怎么办。你认为它来自于数据中大量的“0”吗?

我按照这个例子:

data("EmplUK", package = "plm")
z1 <- pgmm(log(emp) ~ lag(log(emp), 1:2) + lag(log(wage), 0:1)
       + log(capital) + lag(log(output), 0:1) | lag(log(emp), 2:99),
       data = EmplUK, effect = "twoways", model = "twosteps")
Run Code Online (Sandbox Code Playgroud)

但是,我不明白为什么一个滞后是“0:1”而不是“1”。

你能帮我吗?

PS:请原谅我的英语