我正在尝试使用pgmm
中的plm
对面板数据进行工具变量估算。但是,当我尝试这样做时,我得到一个错误。我的代码很复杂,但是这里不需要显示-如果我尝试从R文档本身(这里:https://www.rdocumentation.org/packages/plm/versions/1.6-5/topics/pgmm)执行代码,则会遇到相同的错误。
代码是
library(plm)
data("EmplUK", package = "plm")
## Arellano and Bond (1991), table 4 col. b
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")
我得到了错误
Error: `n` must be a nonnegative integer scalar, not integer of length 2
Traceback:
1. 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")
2. eval(mf, parent.frame())
3. eval(mf, parent.frame())
4. plm(formula = log(emp) ~ lag(log(emp), 1:2) + lag(log(wage),
0:1) + log(capital) + lag(log(output), 0:1) | log(emp) |
log(capital) + log(output) + lag(log(output), 1) + log(wage) +
lag(log(wage), 1), data = EmplUK, drop.unused.levels = TRUE,
model = NA, na.action = "na.pass")
5. eval(mf, parent.frame())
6. eval(mf, parent.frame())
7. model.frame(formula = log(emp) ~ lag(log(emp), 1:2) + lag(log(wage),
0:1) + log(capital) + lag(log(output), 0:1) | log(emp) |
log(capital) + log(output) + lag(log(output), 1) + log(wage) +
lag(log(wage), 1), data = structure(list(firm = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L,
13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 1
以此类推,对于非常很多行。有人可以帮助我了解我的安装情况吗?作为记录,我使用的是plm版本1.6-6(文档大约是1.6-5)。
此外,如果我毫无延迟地尝试同一件事,则会收到不同的错误:
library(plm)
data("EmplUK", package = "plm")
## Arellano and Bond (1991), table 4 col. b
z1 <- pgmm(log(emp) ~ log(wage) | log(capital),
data = EmplUK, effect = "twoways", model = "twosteps")
错误:
Error in cbind(yX1[[i]], V1): number of rows of matrices must match (see
arg 2)
Traceback:
1. pgmm(log(emp) ~ log(wage) | log(capital), data = EmplUK, effect =
"twoways", model = "twosteps")
2. cbind(yX1[[i]], V1)