[英]panel linear model (using plm package) returns “model frame and formula mismatch in model.matrix()”
我正在嘗試根據我擁有的面板數據計算線性模型。
看起來像這樣:
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()
我的猜測是您沒有足夠的數據來計算lag(GDP, 5)
和lag(Gini, 5)
,因此,您將NA作為返回值。 看來您只有3年的可用時間,但您要求這些變量的第5個滯后時間。
直接在控制台中嘗試lag(data.01$GDP, 5)
並查看該輸出[如果data.01是pdata.frame,如果不是,則將其轉換為此類。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.