plm::purtest: object[1:(length(object) - x)] 错误:只有 0 可以与负下标混合
plm::purtest: Error in object[1:(length(object) - x)] : only 0's may be mixed with negative subscripts
我正在尝试进行 Im-Pesaran-Shin 面板单位根测试,但 R 一直向我抛出此错误:
Error in object[1:(length(object) - x)] : only 0's may be mixed with negative subscripts
我已经查看了错误的含义,但不清楚是什么在 plm::purtest() 中抛出错误。
具体来说,我正在处理这个数据集:
> dput(wdi)
structure(list(countrycode = c("BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR"), year = c(1971L, 1972L,
1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L,
1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L,
1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L,
1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L,
2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L,
1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L,
1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L,
1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L,
1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L,
1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L,
1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L,
1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L,
1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L,
1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L,
2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L,
1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L,
2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L,
1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L,
1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L,
1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L,
1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L,
1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L,
1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L
), expenditures_pcgdp = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
18.57386, 18.751022, 19.390184, 19.359026, 19.554941, 24.42634,
25.987106, 23.572901, 30.126379, 36.56868, 34.187275, 23.47085,
28.483221, 36.510372, 32.207279, NA, NA, 21.815582, 21.894501,
21.709864, 21.368114, 22.58164, 22.627327, 24.688396, 22.700518,
25.369011, 27.834694, 26.809689, 27.305458, 26.337072, 30.267986,
30.754955, 30.177795, 30.206541, 31.378775, 36.158054, 35.687759,
34.928814, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 20.510181, NA, NA, NA,
NA, NA, NA, NA, NA, 28.624834, 28.618805, 31.492687, 34.782394,
35.274593, 34.061157, 35.314377, 36.87944, 40.241753, 42.121765,
45.52338, 46.444908, 44.971764, 45.809807, 44.980827, 44.660767,
41.026974, 35.127625, 35.699303, 37.080471, 37.537243, 37.584755,
37.071335, 37.157104, 35.310028, 33.080204, 31.131033, 30.537609,
27.688242, 28.981302, 29.453209, 29.697298, 29.707375, 30.413275,
30.615002, 31.872538, 36.937172, 43.849823, 62.190903, 43.830479,
39.411423, 37.782665, 34.756107, 27.055733, 25.42186, 24.40394,
NA, 10.088495, 10.419682, 11.666667, 12.545455, 13.129103, 12.979989,
12.665811, 13.168188, 10.872793, 12.571509, 21.955528, 21.040037,
18.658382, 20.529604, 24.904715, 27.330492, 23.800133, 19.341707,
16.918575, 13.772678, 13.362055, 10.87185, 10.913582, 11.91382,
11.684354, 12.217944, 11.161502, 11.962865, 12.680059, NA, NA,
NA, NA, NA, NA, NA, 22.104532, 21.570011, 21.403656, 21.732147,
21.873823, 21.551323, 21.794832, 21.630699, 20.977993, 20.551291,
NA, 25.247524, 25.61692, 27.413506, 31.096819, 28.485542, 31.339758,
34.008984, 34.089359, 35.096714, 36.595699, 36.98917, 36.324593,
36.764984, 35.748989, 37.47002, 41.12204, 38.913746, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 31.551292, 30.72579,
31.217342, 30.436657, 30.986078, 31.365622, 31.281376, 32.600452,
34.353168, 34.30434, 40.076042, 35.023129, 33.09127, 32.513466,
31.866594, 30.841063, 30.244081, NA, 12.65359, 13.161526, 11.746681,
13.605937, 14.230906, 13.222456, 15.667478, 13.332707, 18.763405,
17.391436, 16.437389, 18.305017, 17.419443, 17.033836, 16.936241,
15.852185, 13.212941, 12.977591, 19.457102, 14.430077, 17.072933,
15.167376, 15.430264, 17.501808, 17.04991, 16.625416, 16.924335,
17.818132, 18.421289, 18.243986, 17.613434, 17.770838, 17.383371,
18.020134, 17.077677, 18.1434, 17.823631, 18.483582, 17.82234,
17.627886, 17.917788, 18.954376, 20.703936, 20.914022, 19.512623,
20.281525, NA, 17.748812, 17.127398, 18.040783, 19.832541, 20.830061,
21.021811, 21.012228, 21.069654, 19.035093, 20.42724, 22.72263,
24.704796, 24.815081, 26.215103, 27.421268, 27.714472, 28.065773,
27.272587, 27.711384, 27.200689, 30.498302, 31.950811, 28.351601,
28.823311, 29.879169, 28.582968, 28.511471, 28.059881, 27.193941,
27.128674, 26.470325, 27.846453, 28.650305, 28.690125, 28.907198,
29.012487, 29.959778, 32.244446, 31.783628, 32.320011, 33.081799,
34.701942, 34.321373, 35.853924, 34.535339, 34.430107, NA, 23.336748,
23.277695, 24.514791, 24.874428, 27.027029, 30.131639, 32.333992,
33.955139, 34.16431, 36.955612, 37.631519, 39.449322, 38.222195,
39.360039, 37.851521, 36.252819, 35.028114, 34.473179, 35.676899,
37.151897, 40.275459, 44.848915, 42.49633, 42.860813, 40.371529,
38.588623, 37.811268, 36.588802, 34.654915, 33.300312, 33.733418,
33.769047, 32.526688, 33.026478, 31.778162, 31.087246, 31.113777,
33.444366, 32.788441, 32.056057, 32.552181, 33.305042, 32.819454,
31.870672, 31.485804, 31.337461, NA, 14.908337, 15.137362, 12.283178,
14.225877, 14.079203, 15.923507, 16.056641, 18.721428, 18.240738,
15.725858, NA, 16.752722, 17.537312, 16.726931, 13.669138, 14.443557,
14.439909, 14.98505, 15.295647, 19.233305, 18.86739, 22.93519,
21.935106, 20.955494, 25.173187, 27.570986, 21.864641, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 29.87928, 35.954453, 33.555801, 30.999722,
30.320856, 29.989727, 29.894615, 29.03376, 30.836208, 31.929678,
NA, 29.511858, 28.838079, 33.253574, 36.48901, 36.444958, 34.528168,
34.489017, 33.979923, 35.559879, 37.48444, 37.671547, 36.881618,
36.819561, 35.932758, 34.977859, 33.137413, 30.972441, 29.654623,
32.583042, 34.784077, 37.640625, 37.368984, 37.079777, 35.231194,
34.015076, 32.878323, 32.278214, 32.064007, 32.444122, 32.996822,
34.117905, 35.44413, 36.025055, 36.509747, 36.590897, 36.796555,
39.736668, 42.173836, 42.668694, 41.397018, 42.063259, 39.776093,
38.965351, 38.110355, 37.0849, 36.419762), agedepratio = c(82.931709,
81.901657, 80.82663, 79.637421, 78.337425, 77.244598, 76.109596,
74.954445, 73.816582, 72.726616, 72.077133, 71.35627, 70.61274,
69.867432, 69.105843, 68.545952, 67.852531, 67.060593, 66.204407,
65.295174, 64.290749, 63.323193, 62.320408, 61.20837, 59.980881,
58.887756, 57.723915, 56.534389, 55.379333, 54.28643, 53.446384,
52.571552, 51.697498, 50.853268, 50.044228, 49.188732, 48.407051,
47.675579, 46.965405, 46.276161, 45.668896, 45.118832, 44.623783,
44.189659, 43.824265, 43.644318, 43.471035, 93.654572, 94.303688,
94.668945, 94.771027, 94.571213, 94.825691, 94.772957, 94.445572,
93.964439, 93.488815, 93.210777, 92.718567, 92.107185, 91.398659,
90.569069, 90.162369, 89.594406, 88.886932, 88.077095, 87.204109,
86.790482, 86.233612, 85.578415, 84.864082, 84.106422, 83.627251,
83.11528, 82.54203, 81.870735, 81.1036, 80.802834, 80.310379,
79.713921, 79.115265, 78.548485, 78.051186, 77.563339, 77.030861,
76.408806, 75.709976, 75.248726, 74.719223, 74.150696, 73.56472,
72.958336, 72.608185, 72.136475, 71.195663, 71.192047, 71.456429,
71.559555, 71.312447, 71.693222, 71.417168, 70.746895, 70.075005,
69.555946, 69.264709, 69.229332, 69.25042, 69.006073, 68.33709,
67.792969, 66.873779, 65.62571, 64.232254, 62.823437, 60.877613,
59.083473, 57.38168, 55.709702, 54.075077, 52.297222, 50.665005,
49.20039, 47.958763, 46.968361, 46.094597, 45.387348, 44.874535,
44.579624, 44.508358, 44.698906, 45.049824, 45.563839, 46.181278,
46.832077, 48.227726, 49.643017, 51.041523, 52.416599, 53.763546,
54.516586, 55.195694, 100.97634, 101.12232, 101.30132, 101.24901,
100.81917, 100.78103, 100.04939, 98.896317, 97.660126, 96.457138,
94.581139, 93.02182, 91.529411, 89.788124, 87.709747, 85.48317,
83.093506, 80.666954, 78.411591, 76.426743, 74.705933, 73.094383,
71.61937, 70.282234, 69.068718, 68.024612, 67.136322, 66.344002,
65.561371, 64.740204, 63.884403, 62.995811, 62.100426, 61.244801,
60.448498, 59.409908, 58.415142, 57.44503, 56.47892, 55.519535,
54.587555, 53.694649, 52.855999, 52.090576, 51.410007, 50.912548,
50.432297, 66.547775, 65.872124, 65.119904, 64.190498, 63.025288,
62.610508, 61.818306, 60.745243, 59.628761, 58.640125, 57.317196,
56.291706, 55.442329, 54.613243, 53.771111, 53.362682, 52.959312,
52.591366, 52.362022, 52.332661, 52.379318, 52.492287, 52.640377,
52.764015, 52.818283, 53.011585, 53.113224, 53.080429, 52.938091,
52.745636, 52.266438, 51.843834, 51.443302, 51.034573, 50.620441,
50.453308, 50.329483, 50.274757, 50.322002, 50.489616, 51.022743,
51.491615, 51.939129, 52.416862, 52.947323, 53.422169, 54.0536,
91.579765, 91.171135, 90.589897, 89.861389, 89.014755, 88.488884,
87.882889, 87.148468, 86.19709, 84.999428, 84.187119, 82.963264,
81.524696, 80.121834, 78.867966, 77.739166, 76.825897, 75.994583,
75.045448, 73.903, 73.09256, 72.033272, 70.839844, 69.671562,
68.594772, 67.769997, 66.993668, 66.236053, 65.441063, 64.579468,
63.614025, 62.652561, 61.666943, 60.651684, 59.63414, 58.694168,
57.723747, 56.771221, 55.909172, 55.183006, 54.612026, 54.165955,
53.814392, 53.499001, 53.188076, 52.991005, 52.757019, 82.567154,
82.405235, 82.232109, 81.952477, 81.522667, 81.619049, 81.472397,
81.162491, 80.796036, 80.421066, 80.230362, 80.002632, 79.682411,
79.173851, 78.433952, 78.021675, 77.336739, 76.440521, 75.412346,
74.290337, 72.828934, 71.309128, 69.74424, 68.142059, 66.521072,
65.339455, 64.130157, 62.890823, 61.62302, 60.342697, 59.58894,
58.758904, 57.893974, 57.049004, 56.254921, 55.786282, 55.341854,
54.920479, 54.511227, 54.115749, 53.745983, 53.394096, 53.070511,
52.774303, 52.500668, 52.408577, 52.2752, 53.490852, 54.19722,
54.847065, 55.399555, 55.831303, 56.139889, 56.28994, 56.305786,
56.214592, 56.032066, 55.816753, 55.548401, 55.257935, 55.00798,
54.862591, 54.886204, 54.998989, 55.188595, 55.412621, 55.638783,
56.106255, 56.495178, 56.820328, 57.044559, 57.108734, 57.164944,
56.937592, 56.507263, 56.022076, 55.583862, 54.776466, 54.256596,
53.902184, 53.549721, 53.165596, 53.233356, 53.063549, 52.837097,
52.834866, 53.201508, 53.873688, 54.871342, 56.118649, 57.378799,
58.465595, 59.32048, 60.051353, 83.235596, 82.958832, 82.671089,
82.334625, 81.943512, 81.820663, 81.538429, 81.100784, 80.497345,
79.725449, 78.801147, 77.71624, 76.512993, 75.223877, 73.87291,
72.845505, 71.671928, 70.400024, 69.091164, 67.784149, 66.549622,
65.335007, 64.145271, 62.997074, 61.917458, 61.028004, 60.230892,
59.489128, 58.744022, 57.966362, 57.364075, 56.638317, 55.869118,
55.147713, 54.506332, 53.841915, 53.274231, 52.76305, 52.26244,
51.776344, 51.391968, 51.030239, 50.701637, 50.403507, 50.116802,
49.849239, 49.498661, 59.805176, 60.250923, 60.48938, 60.453823,
60.128387, 59.745125, 59.134285, 58.303833, 57.303909, 56.207214,
55.320984, 54.383408, 53.492805, 52.754951, 52.228966, 52.27507,
52.409393, 52.63274, 52.917061, 53.224442, 53.579063, 53.954037,
54.312584, 54.579739, 54.707645, 54.718445, 54.586754, 54.342087,
54.029263, 53.675674, 53.321774, 52.882805, 52.407959, 51.954433,
51.571106, 51.410065, 51.329597, 51.358742, 51.511276, 51.791718,
52.523602, 53.26041, 54.015648, 54.782848, 55.535969, 56.174866,
56.809673), birthrateper1000 = c(34.653999, 34.112, 33.674999,
33.337002, 33.083, 32.894001, 32.734001, 32.563, 32.351002, 32.058998,
31.655001, 31.135, 30.507999, 29.783001, 28.982, 28.134001, 27.278,
26.452, 25.677, 24.979, 24.370001, 23.837999, 23.365, 22.940001,
22.540001, 22.139, 21.716, 21.256001, 20.753, 20.204, 19.618,
19.016001, 18.42, 17.844999, 17.309999, 16.832001, 16.413, 16.052999,
15.749, 15.492, 15.269, 15.06, 14.852, 14.635, 14.405, 14.163,
13.918, 46.403, 46.071999, 45.717999, 45.351002, 44.979, 44.609001,
44.243, 43.881001, 43.521, 43.164001, 42.805, 42.438, 42.057999,
41.661999, 41.244999, 40.799999, 40.332001, 39.846001, 39.353001,
38.867001, 38.408001, 37.987999, 37.612, 37.280998, 36.980999,
36.696999, 36.408001, 36.102001, 35.778999, 35.445999, 35.117001,
34.811001, 34.539001, 34.303001, 34.104, 33.941002, 33.799, 33.660999,
33.513, 33.333, 33.099998, 32.806, 32.448002, 32.028999, 31.556999,
31.047001, 30.52, 22.6, 22.6, 22.299999, 22, 21.1, 20.9, 21,
21.1, 21.5, 21.700001, 20.9, 20.299999, 19.1, 18.1, 17.6, 17.4,
16.5, 15.5, 14.8, 15.1, 14.9, 14.4, 13.8, 13.4, 13.5, 13.9, 14.4,
14.5, 14.4, 14.4, 15, 15.4, 15.4, 15.2, 14.8, 15.3, 16.200001,
16.700001, 16.700001, 16.5, 16.200001, 15.6, 14.9, 14.4, 13.9,
13.4, 12.9, 43.935001, 43.555, 42.903, 41.98, 40.824001, 39.505001,
38.130001, 36.793999, 35.554001, 34.453999, 33.511002, 32.695999,
31.979, 31.354, 30.805, 30.313999, 29.860001, 29.423, 28.989,
28.548, 28.101, 27.653999, 27.212, 26.774, 26.336, 25.899, 25.461,
25.021999, 24.58, 24.132, 23.673, 23.205, 22.731001, 22.259001,
21.799, 21.365999, 20.968, 20.608999, 20.287001, 19.992001, 19.714001,
19.434999, 19.145, 18.837, 18.511999, 18.173, 17.83, 22.6, 21.799999,
20.5, 19.6, 18.299999, 17.700001, 17.299999, 16.299999, 16.799999,
16.200001, 16.200001, 15.8, 15.8, 16, 15.9, 16.299999, 16.799999,
17.299999, 17.5, 17.5, 17.4, 17.280001, 16.530001, 15.95, 15.77,
15.34, 15.23, 14.51, 14.87, 14.66, 14.36, 13.67, 13.94, 14.2,
13.96, 14.14, 15.15, 15.1, 14.53, 14.68, 14, 13.87, 13.2, 12.68,
13.27, 12.65, 12.43, 41.612999, 40.952999, 40.365002, 39.845001,
39.361, 38.862999, 38.306, 37.661999, 36.933998, 36.147999, 35.347,
34.582001, 33.889999, 33.278999, 32.743, 32.261002, 31.794001,
31.311001, 30.798, 30.243, 29.643, 29.011, 28.360001, 27.700001,
27.040001, 26.392, 25.767, 25.172001, 24.615, 24.1, 23.627001,
23.190001, 22.785, 22.41, 22.07, 21.768999, 21.507, 21.278, 21.072001,
20.875999, 20.673, 20.452, 20.202999, 19.924, 19.615, 19.281,
18.936001, 37.632999, 37.471001, 37.282001, 37.061001, 36.806,
36.527, 36.233002, 35.926998, 35.605999, 35.257999, 34.872002,
34.436001, 33.944, 33.393002, 32.780998, 32.104, 31.375999, 30.615999,
29.841, 29.075001, 28.337999, 27.646999, 27.013, 26.448, 25.957001,
25.538, 25.177, 24.861, 24.580999, 24.329, 24.101, 23.892, 23.698,
23.511, 23.330999, 23.159, 22.995001, 22.836, 22.677999, 22.51,
22.322001, 22.108, 21.865, 21.594, 21.297001, 20.981001, 20.655001,
14.1, 13.8, 13.5, 13.5, 12.6, 12, 11.6, 11.3, 11.6, 11.7, 11.3,
11.1, 11, 11.3, 11.8, 12.2, 12.5, 13.3, 13.7, 14.5, 14.4, 14.2,
13.5, 12.8, 11.7, 10.8, 10.2, 10.1, 10, 10.2, 10.3, 10.7, 11.1,
11.2, 11.2, 11.7, 11.7, 11.9, 12, 12.3, 11.8, 11.9, 11.8, 11.9,
11.7, 11.8, 11.5, 39.632, 39.233002, 38.775002, 38.251999, 37.669998,
37.051998, 36.422001, 35.794998, 35.167999, 34.521999, 33.823002,
33.049999, 32.195, 31.27, 30.295, 29.304001, 28.334999, 27.424,
26.594, 25.865, 25.249001, 24.728001, 24.283001, 23.9, 23.552999,
23.219, 22.874001, 22.506001, 22.105, 21.672001, 21.218, 20.763,
20.323999, 19.908001, 19.521, 19.166, 18.837, 18.528999, 18.237,
17.955999, 17.677999, 17.399, 17.115, 16.826, 16.533001, 16.240999,
15.954, 16.1, 14.9, 13.9, 13.1, 12.4, 12, 11.7, 12.2, 13.1, 13.4,
13, 12.8, 12.8, 12.9, 13.3, 13.3, 13.7, 13.8, 13.6, 13.9, 13.8,
13.6, 13.2, 13, 12.6, 12.6, 12.5, 12.3, 11.9, 11.5, 11.3, 11.3,
11.7, 11.9, 12, 12.3, 12.6, 12.9, 12.7, 12.9, 12.8, 12.8, 12.1,
12, 11.9, 11.8, 11.4)), class = "data.frame", row.names = c(NA,
-470L))
并且正在尝试对 expenditures_pcgdp 列执行 ips 测试:
purtest(expenditures_pcgdp ~ 0, data = wdi, test = 'ips', index = c('countrycode', 'year'), lags = 'SIC', pmax = 10)
任何更熟悉这个包如何工作的人知道我做错了什么以及如何解决它?
编辑:为清楚起见调整了一些语言
除了错误之外,您还应该收到有关 NA 删除的警告:
In addition: Warning message:
In purtest(expenditures_pcgdp ~ 0, data = wdi, test = "ips", index = c("countrycode", :
NA value(s) encountered and dropped, results may not be reliable
如果不是,请更新您的软件包版本 plm
。这个警告提示我仔细查看 after NA dropping: for observational unit "GHA", there only one observation left and that is the root cause for the error.滞后于此,将不会留下任何针对此个体和代码错误的观察结果。在这种情况下,包应该给出更好的错误消息...
删除此人后,代码将 运行。但是,请注意 IPS 测试并不意味着在没有外生变量的情况下执行。因此,在下面的代码中,我引入了截距(~ 1
而不是 ~ 0
)。
pwdi <- pdata.frame(wdi)
pdim <- pdim(pwdi)
pdim$Tint # balanced panel 47 obs per unit
pwdi2 <- pdata.frame(na.omit(wdi[ , c('countrycode', 'year', 'expenditures_pcgdp')]))
pdim2 <- pdim(pwdi2)
pdim2$Tint # after NA dropping: GHA has only 1 observation
pwdi3 <- pwdi2[pwdi2$countrycode != "GHA", ] # remove offending unit completely
# run IPS test with intercepts as exogeneous variables
purtest(expenditures_pcgdp ~ 1, data = pwdi3, test = 'ips', lags = 'SIC', pmax = 10)
# Im-Pesaran-Shin Unit-Root Test (ex. var.: Individual Intercepts)
#
# data: expenditures_pcgdp ~ 1
# Wtbar = -1.7792, p-value = 0.03761
# alternative hypothesis: stationarity
我正在尝试进行 Im-Pesaran-Shin 面板单位根测试,但 R 一直向我抛出此错误:
Error in object[1:(length(object) - x)] : only 0's may be mixed with negative subscripts
我已经查看了错误的含义,但不清楚是什么在 plm::purtest() 中抛出错误。
具体来说,我正在处理这个数据集:
> dput(wdi)
structure(list(countrycode = c("BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "BRA",
"BRA", "BRA", "BRA", "BRA", "BRA", "BRA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA",
"GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL", "IRL",
"IRL", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX", "MEX",
"MEX", "MEX", "MEX", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL", "NZL",
"NZL", "NZL", "NZL", "NZL", "NZL", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER", "PER",
"PER", "PER", "PER", "PER", "PER", "PER", "PER", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE", "SWE",
"SWE", "SWE", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR", "TUR",
"TUR", "TUR", "TUR", "TUR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR", "GBR",
"GBR", "GBR", "GBR", "GBR", "GBR", "GBR"), year = c(1971L, 1972L,
1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L,
1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L,
1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L,
1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L,
1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L,
1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L,
2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L,
2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L,
1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L,
1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L,
1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L,
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L,
2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L,
1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L,
1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L,
1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L,
2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L,
2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L,
1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L,
1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L,
1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L,
2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L,
2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L,
1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L,
1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L,
1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L,
1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L,
2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L,
2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L, 1977L, 1978L,
1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L, 1986L, 1987L,
1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L, 1995L, 1996L,
1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L,
2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L, 2013L, 2014L,
2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L, 1975L, 1976L,
1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L, 1984L, 1985L,
1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L, 1993L, 1994L,
1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L,
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L, 1973L, 1974L,
1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L, 1982L, 1983L,
1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L, 1991L, 1992L,
1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L,
2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L,
2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L, 1971L, 1972L,
1973L, 1974L, 1975L, 1976L, 1977L, 1978L, 1979L, 1980L, 1981L,
1982L, 1983L, 1984L, 1985L, 1986L, 1987L, 1988L, 1989L, 1990L,
1991L, 1992L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L,
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L
), expenditures_pcgdp = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
18.57386, 18.751022, 19.390184, 19.359026, 19.554941, 24.42634,
25.987106, 23.572901, 30.126379, 36.56868, 34.187275, 23.47085,
28.483221, 36.510372, 32.207279, NA, NA, 21.815582, 21.894501,
21.709864, 21.368114, 22.58164, 22.627327, 24.688396, 22.700518,
25.369011, 27.834694, 26.809689, 27.305458, 26.337072, 30.267986,
30.754955, 30.177795, 30.206541, 31.378775, 36.158054, 35.687759,
34.928814, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 20.510181, NA, NA, NA,
NA, NA, NA, NA, NA, 28.624834, 28.618805, 31.492687, 34.782394,
35.274593, 34.061157, 35.314377, 36.87944, 40.241753, 42.121765,
45.52338, 46.444908, 44.971764, 45.809807, 44.980827, 44.660767,
41.026974, 35.127625, 35.699303, 37.080471, 37.537243, 37.584755,
37.071335, 37.157104, 35.310028, 33.080204, 31.131033, 30.537609,
27.688242, 28.981302, 29.453209, 29.697298, 29.707375, 30.413275,
30.615002, 31.872538, 36.937172, 43.849823, 62.190903, 43.830479,
39.411423, 37.782665, 34.756107, 27.055733, 25.42186, 24.40394,
NA, 10.088495, 10.419682, 11.666667, 12.545455, 13.129103, 12.979989,
12.665811, 13.168188, 10.872793, 12.571509, 21.955528, 21.040037,
18.658382, 20.529604, 24.904715, 27.330492, 23.800133, 19.341707,
16.918575, 13.772678, 13.362055, 10.87185, 10.913582, 11.91382,
11.684354, 12.217944, 11.161502, 11.962865, 12.680059, NA, NA,
NA, NA, NA, NA, NA, 22.104532, 21.570011, 21.403656, 21.732147,
21.873823, 21.551323, 21.794832, 21.630699, 20.977993, 20.551291,
NA, 25.247524, 25.61692, 27.413506, 31.096819, 28.485542, 31.339758,
34.008984, 34.089359, 35.096714, 36.595699, 36.98917, 36.324593,
36.764984, 35.748989, 37.47002, 41.12204, 38.913746, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 31.551292, 30.72579,
31.217342, 30.436657, 30.986078, 31.365622, 31.281376, 32.600452,
34.353168, 34.30434, 40.076042, 35.023129, 33.09127, 32.513466,
31.866594, 30.841063, 30.244081, NA, 12.65359, 13.161526, 11.746681,
13.605937, 14.230906, 13.222456, 15.667478, 13.332707, 18.763405,
17.391436, 16.437389, 18.305017, 17.419443, 17.033836, 16.936241,
15.852185, 13.212941, 12.977591, 19.457102, 14.430077, 17.072933,
15.167376, 15.430264, 17.501808, 17.04991, 16.625416, 16.924335,
17.818132, 18.421289, 18.243986, 17.613434, 17.770838, 17.383371,
18.020134, 17.077677, 18.1434, 17.823631, 18.483582, 17.82234,
17.627886, 17.917788, 18.954376, 20.703936, 20.914022, 19.512623,
20.281525, NA, 17.748812, 17.127398, 18.040783, 19.832541, 20.830061,
21.021811, 21.012228, 21.069654, 19.035093, 20.42724, 22.72263,
24.704796, 24.815081, 26.215103, 27.421268, 27.714472, 28.065773,
27.272587, 27.711384, 27.200689, 30.498302, 31.950811, 28.351601,
28.823311, 29.879169, 28.582968, 28.511471, 28.059881, 27.193941,
27.128674, 26.470325, 27.846453, 28.650305, 28.690125, 28.907198,
29.012487, 29.959778, 32.244446, 31.783628, 32.320011, 33.081799,
34.701942, 34.321373, 35.853924, 34.535339, 34.430107, NA, 23.336748,
23.277695, 24.514791, 24.874428, 27.027029, 30.131639, 32.333992,
33.955139, 34.16431, 36.955612, 37.631519, 39.449322, 38.222195,
39.360039, 37.851521, 36.252819, 35.028114, 34.473179, 35.676899,
37.151897, 40.275459, 44.848915, 42.49633, 42.860813, 40.371529,
38.588623, 37.811268, 36.588802, 34.654915, 33.300312, 33.733418,
33.769047, 32.526688, 33.026478, 31.778162, 31.087246, 31.113777,
33.444366, 32.788441, 32.056057, 32.552181, 33.305042, 32.819454,
31.870672, 31.485804, 31.337461, NA, 14.908337, 15.137362, 12.283178,
14.225877, 14.079203, 15.923507, 16.056641, 18.721428, 18.240738,
15.725858, NA, 16.752722, 17.537312, 16.726931, 13.669138, 14.443557,
14.439909, 14.98505, 15.295647, 19.233305, 18.86739, 22.93519,
21.935106, 20.955494, 25.173187, 27.570986, 21.864641, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 29.87928, 35.954453, 33.555801, 30.999722,
30.320856, 29.989727, 29.894615, 29.03376, 30.836208, 31.929678,
NA, 29.511858, 28.838079, 33.253574, 36.48901, 36.444958, 34.528168,
34.489017, 33.979923, 35.559879, 37.48444, 37.671547, 36.881618,
36.819561, 35.932758, 34.977859, 33.137413, 30.972441, 29.654623,
32.583042, 34.784077, 37.640625, 37.368984, 37.079777, 35.231194,
34.015076, 32.878323, 32.278214, 32.064007, 32.444122, 32.996822,
34.117905, 35.44413, 36.025055, 36.509747, 36.590897, 36.796555,
39.736668, 42.173836, 42.668694, 41.397018, 42.063259, 39.776093,
38.965351, 38.110355, 37.0849, 36.419762), agedepratio = c(82.931709,
81.901657, 80.82663, 79.637421, 78.337425, 77.244598, 76.109596,
74.954445, 73.816582, 72.726616, 72.077133, 71.35627, 70.61274,
69.867432, 69.105843, 68.545952, 67.852531, 67.060593, 66.204407,
65.295174, 64.290749, 63.323193, 62.320408, 61.20837, 59.980881,
58.887756, 57.723915, 56.534389, 55.379333, 54.28643, 53.446384,
52.571552, 51.697498, 50.853268, 50.044228, 49.188732, 48.407051,
47.675579, 46.965405, 46.276161, 45.668896, 45.118832, 44.623783,
44.189659, 43.824265, 43.644318, 43.471035, 93.654572, 94.303688,
94.668945, 94.771027, 94.571213, 94.825691, 94.772957, 94.445572,
93.964439, 93.488815, 93.210777, 92.718567, 92.107185, 91.398659,
90.569069, 90.162369, 89.594406, 88.886932, 88.077095, 87.204109,
86.790482, 86.233612, 85.578415, 84.864082, 84.106422, 83.627251,
83.11528, 82.54203, 81.870735, 81.1036, 80.802834, 80.310379,
79.713921, 79.115265, 78.548485, 78.051186, 77.563339, 77.030861,
76.408806, 75.709976, 75.248726, 74.719223, 74.150696, 73.56472,
72.958336, 72.608185, 72.136475, 71.195663, 71.192047, 71.456429,
71.559555, 71.312447, 71.693222, 71.417168, 70.746895, 70.075005,
69.555946, 69.264709, 69.229332, 69.25042, 69.006073, 68.33709,
67.792969, 66.873779, 65.62571, 64.232254, 62.823437, 60.877613,
59.083473, 57.38168, 55.709702, 54.075077, 52.297222, 50.665005,
49.20039, 47.958763, 46.968361, 46.094597, 45.387348, 44.874535,
44.579624, 44.508358, 44.698906, 45.049824, 45.563839, 46.181278,
46.832077, 48.227726, 49.643017, 51.041523, 52.416599, 53.763546,
54.516586, 55.195694, 100.97634, 101.12232, 101.30132, 101.24901,
100.81917, 100.78103, 100.04939, 98.896317, 97.660126, 96.457138,
94.581139, 93.02182, 91.529411, 89.788124, 87.709747, 85.48317,
83.093506, 80.666954, 78.411591, 76.426743, 74.705933, 73.094383,
71.61937, 70.282234, 69.068718, 68.024612, 67.136322, 66.344002,
65.561371, 64.740204, 63.884403, 62.995811, 62.100426, 61.244801,
60.448498, 59.409908, 58.415142, 57.44503, 56.47892, 55.519535,
54.587555, 53.694649, 52.855999, 52.090576, 51.410007, 50.912548,
50.432297, 66.547775, 65.872124, 65.119904, 64.190498, 63.025288,
62.610508, 61.818306, 60.745243, 59.628761, 58.640125, 57.317196,
56.291706, 55.442329, 54.613243, 53.771111, 53.362682, 52.959312,
52.591366, 52.362022, 52.332661, 52.379318, 52.492287, 52.640377,
52.764015, 52.818283, 53.011585, 53.113224, 53.080429, 52.938091,
52.745636, 52.266438, 51.843834, 51.443302, 51.034573, 50.620441,
50.453308, 50.329483, 50.274757, 50.322002, 50.489616, 51.022743,
51.491615, 51.939129, 52.416862, 52.947323, 53.422169, 54.0536,
91.579765, 91.171135, 90.589897, 89.861389, 89.014755, 88.488884,
87.882889, 87.148468, 86.19709, 84.999428, 84.187119, 82.963264,
81.524696, 80.121834, 78.867966, 77.739166, 76.825897, 75.994583,
75.045448, 73.903, 73.09256, 72.033272, 70.839844, 69.671562,
68.594772, 67.769997, 66.993668, 66.236053, 65.441063, 64.579468,
63.614025, 62.652561, 61.666943, 60.651684, 59.63414, 58.694168,
57.723747, 56.771221, 55.909172, 55.183006, 54.612026, 54.165955,
53.814392, 53.499001, 53.188076, 52.991005, 52.757019, 82.567154,
82.405235, 82.232109, 81.952477, 81.522667, 81.619049, 81.472397,
81.162491, 80.796036, 80.421066, 80.230362, 80.002632, 79.682411,
79.173851, 78.433952, 78.021675, 77.336739, 76.440521, 75.412346,
74.290337, 72.828934, 71.309128, 69.74424, 68.142059, 66.521072,
65.339455, 64.130157, 62.890823, 61.62302, 60.342697, 59.58894,
58.758904, 57.893974, 57.049004, 56.254921, 55.786282, 55.341854,
54.920479, 54.511227, 54.115749, 53.745983, 53.394096, 53.070511,
52.774303, 52.500668, 52.408577, 52.2752, 53.490852, 54.19722,
54.847065, 55.399555, 55.831303, 56.139889, 56.28994, 56.305786,
56.214592, 56.032066, 55.816753, 55.548401, 55.257935, 55.00798,
54.862591, 54.886204, 54.998989, 55.188595, 55.412621, 55.638783,
56.106255, 56.495178, 56.820328, 57.044559, 57.108734, 57.164944,
56.937592, 56.507263, 56.022076, 55.583862, 54.776466, 54.256596,
53.902184, 53.549721, 53.165596, 53.233356, 53.063549, 52.837097,
52.834866, 53.201508, 53.873688, 54.871342, 56.118649, 57.378799,
58.465595, 59.32048, 60.051353, 83.235596, 82.958832, 82.671089,
82.334625, 81.943512, 81.820663, 81.538429, 81.100784, 80.497345,
79.725449, 78.801147, 77.71624, 76.512993, 75.223877, 73.87291,
72.845505, 71.671928, 70.400024, 69.091164, 67.784149, 66.549622,
65.335007, 64.145271, 62.997074, 61.917458, 61.028004, 60.230892,
59.489128, 58.744022, 57.966362, 57.364075, 56.638317, 55.869118,
55.147713, 54.506332, 53.841915, 53.274231, 52.76305, 52.26244,
51.776344, 51.391968, 51.030239, 50.701637, 50.403507, 50.116802,
49.849239, 49.498661, 59.805176, 60.250923, 60.48938, 60.453823,
60.128387, 59.745125, 59.134285, 58.303833, 57.303909, 56.207214,
55.320984, 54.383408, 53.492805, 52.754951, 52.228966, 52.27507,
52.409393, 52.63274, 52.917061, 53.224442, 53.579063, 53.954037,
54.312584, 54.579739, 54.707645, 54.718445, 54.586754, 54.342087,
54.029263, 53.675674, 53.321774, 52.882805, 52.407959, 51.954433,
51.571106, 51.410065, 51.329597, 51.358742, 51.511276, 51.791718,
52.523602, 53.26041, 54.015648, 54.782848, 55.535969, 56.174866,
56.809673), birthrateper1000 = c(34.653999, 34.112, 33.674999,
33.337002, 33.083, 32.894001, 32.734001, 32.563, 32.351002, 32.058998,
31.655001, 31.135, 30.507999, 29.783001, 28.982, 28.134001, 27.278,
26.452, 25.677, 24.979, 24.370001, 23.837999, 23.365, 22.940001,
22.540001, 22.139, 21.716, 21.256001, 20.753, 20.204, 19.618,
19.016001, 18.42, 17.844999, 17.309999, 16.832001, 16.413, 16.052999,
15.749, 15.492, 15.269, 15.06, 14.852, 14.635, 14.405, 14.163,
13.918, 46.403, 46.071999, 45.717999, 45.351002, 44.979, 44.609001,
44.243, 43.881001, 43.521, 43.164001, 42.805, 42.438, 42.057999,
41.661999, 41.244999, 40.799999, 40.332001, 39.846001, 39.353001,
38.867001, 38.408001, 37.987999, 37.612, 37.280998, 36.980999,
36.696999, 36.408001, 36.102001, 35.778999, 35.445999, 35.117001,
34.811001, 34.539001, 34.303001, 34.104, 33.941002, 33.799, 33.660999,
33.513, 33.333, 33.099998, 32.806, 32.448002, 32.028999, 31.556999,
31.047001, 30.52, 22.6, 22.6, 22.299999, 22, 21.1, 20.9, 21,
21.1, 21.5, 21.700001, 20.9, 20.299999, 19.1, 18.1, 17.6, 17.4,
16.5, 15.5, 14.8, 15.1, 14.9, 14.4, 13.8, 13.4, 13.5, 13.9, 14.4,
14.5, 14.4, 14.4, 15, 15.4, 15.4, 15.2, 14.8, 15.3, 16.200001,
16.700001, 16.700001, 16.5, 16.200001, 15.6, 14.9, 14.4, 13.9,
13.4, 12.9, 43.935001, 43.555, 42.903, 41.98, 40.824001, 39.505001,
38.130001, 36.793999, 35.554001, 34.453999, 33.511002, 32.695999,
31.979, 31.354, 30.805, 30.313999, 29.860001, 29.423, 28.989,
28.548, 28.101, 27.653999, 27.212, 26.774, 26.336, 25.899, 25.461,
25.021999, 24.58, 24.132, 23.673, 23.205, 22.731001, 22.259001,
21.799, 21.365999, 20.968, 20.608999, 20.287001, 19.992001, 19.714001,
19.434999, 19.145, 18.837, 18.511999, 18.173, 17.83, 22.6, 21.799999,
20.5, 19.6, 18.299999, 17.700001, 17.299999, 16.299999, 16.799999,
16.200001, 16.200001, 15.8, 15.8, 16, 15.9, 16.299999, 16.799999,
17.299999, 17.5, 17.5, 17.4, 17.280001, 16.530001, 15.95, 15.77,
15.34, 15.23, 14.51, 14.87, 14.66, 14.36, 13.67, 13.94, 14.2,
13.96, 14.14, 15.15, 15.1, 14.53, 14.68, 14, 13.87, 13.2, 12.68,
13.27, 12.65, 12.43, 41.612999, 40.952999, 40.365002, 39.845001,
39.361, 38.862999, 38.306, 37.661999, 36.933998, 36.147999, 35.347,
34.582001, 33.889999, 33.278999, 32.743, 32.261002, 31.794001,
31.311001, 30.798, 30.243, 29.643, 29.011, 28.360001, 27.700001,
27.040001, 26.392, 25.767, 25.172001, 24.615, 24.1, 23.627001,
23.190001, 22.785, 22.41, 22.07, 21.768999, 21.507, 21.278, 21.072001,
20.875999, 20.673, 20.452, 20.202999, 19.924, 19.615, 19.281,
18.936001, 37.632999, 37.471001, 37.282001, 37.061001, 36.806,
36.527, 36.233002, 35.926998, 35.605999, 35.257999, 34.872002,
34.436001, 33.944, 33.393002, 32.780998, 32.104, 31.375999, 30.615999,
29.841, 29.075001, 28.337999, 27.646999, 27.013, 26.448, 25.957001,
25.538, 25.177, 24.861, 24.580999, 24.329, 24.101, 23.892, 23.698,
23.511, 23.330999, 23.159, 22.995001, 22.836, 22.677999, 22.51,
22.322001, 22.108, 21.865, 21.594, 21.297001, 20.981001, 20.655001,
14.1, 13.8, 13.5, 13.5, 12.6, 12, 11.6, 11.3, 11.6, 11.7, 11.3,
11.1, 11, 11.3, 11.8, 12.2, 12.5, 13.3, 13.7, 14.5, 14.4, 14.2,
13.5, 12.8, 11.7, 10.8, 10.2, 10.1, 10, 10.2, 10.3, 10.7, 11.1,
11.2, 11.2, 11.7, 11.7, 11.9, 12, 12.3, 11.8, 11.9, 11.8, 11.9,
11.7, 11.8, 11.5, 39.632, 39.233002, 38.775002, 38.251999, 37.669998,
37.051998, 36.422001, 35.794998, 35.167999, 34.521999, 33.823002,
33.049999, 32.195, 31.27, 30.295, 29.304001, 28.334999, 27.424,
26.594, 25.865, 25.249001, 24.728001, 24.283001, 23.9, 23.552999,
23.219, 22.874001, 22.506001, 22.105, 21.672001, 21.218, 20.763,
20.323999, 19.908001, 19.521, 19.166, 18.837, 18.528999, 18.237,
17.955999, 17.677999, 17.399, 17.115, 16.826, 16.533001, 16.240999,
15.954, 16.1, 14.9, 13.9, 13.1, 12.4, 12, 11.7, 12.2, 13.1, 13.4,
13, 12.8, 12.8, 12.9, 13.3, 13.3, 13.7, 13.8, 13.6, 13.9, 13.8,
13.6, 13.2, 13, 12.6, 12.6, 12.5, 12.3, 11.9, 11.5, 11.3, 11.3,
11.7, 11.9, 12, 12.3, 12.6, 12.9, 12.7, 12.9, 12.8, 12.8, 12.1,
12, 11.9, 11.8, 11.4)), class = "data.frame", row.names = c(NA,
-470L))
并且正在尝试对 expenditures_pcgdp 列执行 ips 测试:
purtest(expenditures_pcgdp ~ 0, data = wdi, test = 'ips', index = c('countrycode', 'year'), lags = 'SIC', pmax = 10)
任何更熟悉这个包如何工作的人知道我做错了什么以及如何解决它?
编辑:为清楚起见调整了一些语言
除了错误之外,您还应该收到有关 NA 删除的警告:
In addition: Warning message:
In purtest(expenditures_pcgdp ~ 0, data = wdi, test = "ips", index = c("countrycode", :
NA value(s) encountered and dropped, results may not be reliable
如果不是,请更新您的软件包版本 plm
。这个警告提示我仔细查看 after NA dropping: for observational unit "GHA", there only one observation left and that is the root cause for the error.滞后于此,将不会留下任何针对此个体和代码错误的观察结果。在这种情况下,包应该给出更好的错误消息...
删除此人后,代码将 运行。但是,请注意 IPS 测试并不意味着在没有外生变量的情况下执行。因此,在下面的代码中,我引入了截距(~ 1
而不是 ~ 0
)。
pwdi <- pdata.frame(wdi)
pdim <- pdim(pwdi)
pdim$Tint # balanced panel 47 obs per unit
pwdi2 <- pdata.frame(na.omit(wdi[ , c('countrycode', 'year', 'expenditures_pcgdp')]))
pdim2 <- pdim(pwdi2)
pdim2$Tint # after NA dropping: GHA has only 1 observation
pwdi3 <- pwdi2[pwdi2$countrycode != "GHA", ] # remove offending unit completely
# run IPS test with intercepts as exogeneous variables
purtest(expenditures_pcgdp ~ 1, data = pwdi3, test = 'ips', lags = 'SIC', pmax = 10)
# Im-Pesaran-Shin Unit-Root Test (ex. var.: Individual Intercepts)
#
# data: expenditures_pcgdp ~ 1
# Wtbar = -1.7792, p-value = 0.03761
# alternative hypothesis: stationarity