我正在使用 R 中的面板数据运行计量经济学模型。我正在使用 plm 包和池化模型,并且固定效应模型效果很好。但是我在尝试做随机效应模型时遇到了这个错误,我不知道如何解决它。
这是我的整个数据集和代码:
auto <- structure(list(Country = structure(c(1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 6L, 6L,
6L, 6L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 10L,
10L, 10L, 10L, 11L, 11L, 11L, 11L), .Label = c("Bahrain", "Cuba",
"China", "Kuwait", "Lao PDR", "Qatar", "Saudi Arabia", "Swaziland",
"Syria", "United Arab Emirates", "Vietnam"), class = "factor"),
Year = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L,
3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,
2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L,
1L, 2L, 3L, 4L), .Label = c("1971", "1981", "1991", "2001"
), class = "factor"), AVG_GR_. = c(2.44, -2.93, 1.77, -1.04,
3.17, 3.5, -1.59, 5.13, 4.29, 7.51, 9.42, 9.83, -7.39, -5.52,
10.72, -0.14, 1.77, 3.38, 3.68, 5.33, -1.55, -5.72, 4.64,
1.5, 6.06, -5.25, 0.54, 2.28, 6.99, 2.82, 0.82, 1.12, 6.72,
-2, 3.09, 2.15, -1.06, -4.88, 0.2, -6.04, 1.61, 3.21, 5.88,
6.24), GDP_PC = c(17444.65, 19550.76, 15970.05, 18212.71,
2067.93, 3127.98, 3221.25, 3081.73, 153.5, 231.14, 491.26,
1207.52, 70184.35, 23911.92, 9559.35, 27681.03, 162.06, 212.46,
261.98, 386.38, 72617.74, 55370.39, 31970, 51090.02, 13752.55,
21124.79, 12891.51, 12446.49, 881.75, 1595.82, 1995.8, 2191.36,
738.63, 1349.2, 1057.84, 1380.2, 88377.72, 75348.77, 43306.13,
45038.43, 164.15, 194.45, 267.17, 481.92), POP_. = c(5.39,
3.26, 3.03, 6.49, 1.22, 0.75, 0.5, 0.13, 1.91, 1.71, 0.95,
0.6, 6.22, 4.16, -0.66, 4.61, 1.93, 2.7, 2.42, 1.73, 7.44,
7.9, 2.23, 11.57, 5.43, 5.12, 2.2, 3.08, 3.07, 3.64, 2.12,
1.16, 3.45, 3.35, 2.77, 2.78, 15.96, 5.94, 5.3, 10.95, 2.29,
2.3, 1.62, 0.97), CONSUMP_. = c(64.21, 52.81, 51.47, 40.51,
54.58, 54.96, 62.74, 54.02, 51.72, 51.01, 45.63, 39, 27.44,
48.61, 49.76, 35.74, 90.19, 90.65, 89.15, 70.38, 21.33, 26.27,
26.84, 16.81, 22.96, 46.85, 44.2, 31.61, 54.77, 74.9, 80.42,
79.36, 67.09, 69.71, 69.92, 61.26, 15.28, 33.07, 46.79, 59.97,
90, 89.89, 73.9, 65.33), GOV_CON_. = c(11.1, 19.55, 19.21,
14.27, 31.67, 31.66, 29.47, 34.91, 12.99, 14.11, 14.53, 14.1,
12.04, 23.7, 48.98, 18.45, 8.05, 8.29, 7.21, 8.96, 20.47,
36.49, 31.09, 14.5, 16.02, 30.12, 26.94, 22.53, 19.07, 17.11,
17.65, 14.76, 19.93, 19.6, 12.75, 12.67, 10.87, 19.27, 16.99,
7.66, 6.73, 6.85, 7.46, 6.19), CAP_FORM_. = c(34.15, 32.51,
24.24, 26.56, 25.94, 25.49, 10.76, 10.7, 34.57, 35.19, 37.79,
42.21, 13.55, 18.68, 17.9, 17.28, 7.57, 10.24, 16.68, 30.28,
22.49, 18.37, 26.13, 36.58, 22.59, 22.7, 20.49, 23.68, 30.77,
21.42, 17.65, 14.55, 25.34, 20.68, 22.53, 23.48, 29.93, 26.28,
27.29, 22.63, 14.45, 14.46, 25.22, 36.44), NAT_RES_. = c(27.42,
20.18, 17.52, 23.34, 1.81, 1.87, 2.5, 3.42, 41.09, 38.83,
40.09, 17.91, 66.53, 41.25, 35.94, 48.41, 5.28, 4.2, 3.01,
10.15, 63.5, 40.84, 39.7, 54.17, 57.89, 31.24, 32.74, 42.77,
6.47, 3.64, 2.25, 1.32, 9.55, 9.14, 14.19, 22.92, 51.04,
37.08, 27.99, 31.36, 3.95, 4.17, 8.39, 13.57), TRADE = c(1.69,
1.48, 1.37, 1.34, 0.77, 0.76, 0.33, 0.34, 0.11, 0.21, 0.35,
0.58, 1.03, 0.99, 1.09, 0.9, 0.15, 0.23, 0.63, 0.57, 0.95,
0.82, 0.85, 0.91, 0.89, 0.76, 0.66, 0.8, 1.47, 1.54, 1.42,
1.62, 0.51, 0.44, 0.66, 0.71, 1.1, 0.97, 1.37, 1.23, 0.62,
0.62, 0.86, 1.43), INFL_. = c(13.26, 3.24, 1.64, 5.65, 5.22,
0.11, 5.49, 2.44, 1.17, 5.72, 6.85, 4.2, 31.52, -0.47, 3.25,
7.29, 43.86, 56.9, 32.37, 7.95, 20.84, -1.59, 3.18, 8.65,
26.67, -1.16, 2.4, 5.73, 10.71, 11.36, 10.97, 8.04, 11.62,
17.43, 6.74, 6.78, 28.31, 1.25, 2.03, 6.94, 7.05, 156.6,
18.99, 9.45), LIFE_EXP = c(67.39, 71.47, 73.66, 75.55, 72.28,
74.46, 75.6, 77.81, 65.7, 68.43, 70.64, 73.99, 68.17, 71.25,
72.92, 73.79, 47.79, 51.39, 58.38, 64.68, 71.16, 74.31, 76.18,
77.53, 58.65, 66.77, 71.16, 74.03, 51.33, 57.45, 54.96, 46.81,
63.01, 68.42, 72.03, 74.56, 65.49, 70.19, 73.24, 75.66, 62.69,
69.09, 72.28, 74.66), EDU_T = c(0.68, 1.59, 2.63, 3.14, 0.75,
1.46, 2.81, 3.84, 0.37, 0.62, 1.08, 1.71, 1.41, 2.71, 3.53,
3.54, 0.16, 0.35, 0.65, 1, 1.61, 2.11, 2.5, 3.06, 1.06, 1.44,
2.13, 2.66, 0.35, 0.74, 1.07, 0.91, 0.34, 0.74, 1.27, 1.3,
1.14, 1.65, 2.61, 3.85, 0.67, 1.21, 0.67, 1.54)), .Names = c("Country",
"Year", "AVG_GR_.", "GDP_PC", "POP_.", "CONSUMP_.", "GOV_CON_.",
"CAP_FORM_.", "NAT_RES_.", "TRADE", "INFL_.", "LIFE_EXP", "EDU_T"
), row.names = c(1L, 2L, 3L, 4L, 9L, 10L, 11L, 12L, 5L, 6L, 7L,
8L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 25L, 26L, 27L, 28L,
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L), class = c("plm.dim", "data.frame"
))
Y <- cbind(auto$AVG_GR_.)
X <- cbind(auto$GDP_PC, auto$POP_., auto$CONSUMP_., auto$GOV_CON_.,
auto$CAP_FORM_., auto$NAT_RES_., auto$TRADE, auto$INFL_.,
auto$LIFE_EXP, auto$EDU_T)
pdata <- plm.data(auto, c("Country", "Year"))
random <- plm(Y~X, data=pdata, model="random")
一切正常,直到最后一行。我收到此错误:
if (sigma2$id < 0) stop(paste("the 的估计方差", : 需要 TRUE/FALSE 的缺失值) 中的错误
谢谢你的帮助 :)