1

我正在尝试根据我拥有的面板数据计算线性模型。

它看起来像这样:

model <- plm((log(GDP)-log(lag(GDP,5))) ~ log(lag(GDP,5)) + (lag(Gini,5)) 
+ GFCF + Schooling, data=data.01, index=c("Country", "Year"), model="within")

面板看起来像这样

Country  Year   GDP     Gini   GFCF  Schooling
A        1970   21400   0.33   0.22   10.11
A        1971   21350   0.34   0.23   10.70
A        1972   21600   0.33   0.23   10.90
B        1970   18500   0.29   0.17    9.80
B        1971   19000   0.28   0.17    9.90
B        1972   20800   0.28   0.15   10.50

知道为什么 R 一直返回这个吗?

series Gini, X are NA and have been removed
Error in model.matrix.default(mt, data = data, ...) : 
  model frame and formula mismatch in model.matrix()
4

1 回答 1

0

我的猜测是你没有足够的数据来计算lag(GDP, 5)lag(Gini, 5)计算,因此你得到 NA 作为返回值。看起来您只有 3 年可用,但您要求这些变量的第 5 个滞后。

直接在控制台中尝试lag(data.01$GDP, 5)并查看该输出[如果 data.01 是 pdata.frame,如果不是,则将其转换为此类]。

于 2016-02-10T13:17:47.240 回答