R中面板数据模型中同一自变量的几个系数

Several coefficients for the same independant variable in panel data model in R

我正在使用 R 中的 plm 包来估计以下简单的面板数据模型: X1 ~ X2 22 个国家和 18 年(年度数据)。

在下面,您可以找到我的数据的摘录以作为可重现的示例。

我的代码如下:

form <- X1 ~ X2
pdata <- pdata.frame(data, index=c("id","t"), drop.index=TRUE, row.names=TRUE)
fit.pooling <- plm(form, data = pdata, model = "pooling")
summary(fit.pooling)

我应该得到 X2 的一个系数,但我却得到了几个系数(显然每个观察一个)。

有谁知道我为什么会得到这个结果,我该如何纠正这个问题?

这是我的结果:

Results

structure(list(t = c(1996, 1997, 1998, 1999, 2000, 2001, 2002, 
2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 
2007, 2008, 2009, 2010, 2011, 2012, 2013, 1996, 1997, 1998, 1999, 
2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 
2011, 2012, 2013, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 1996, 
1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 
2008, 2009, 2010, 2011, 2012, 2013, 1996, 1997, 1998, 1999, 2000, 
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 
2012, 2013, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 
2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 1996, 1997, 
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 
2009, 2010, 2011, 2012, 2013), id = c("Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Australia", "Australia", "Australia", "Australia", 
"Australia", "Austria", "Austria", "Austria", "Austria", "Austria", 
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria", 
"Austria", "Austria", "Austria", "Austria", "Austria", "Austria", 
"Austria", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", 
"Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", 
"Belgium", "Belgium", "Belgium", "Belgium", "Belgium", "Belgium", 
"Belgium", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", 
"Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", 
"Denmark", "Denmark", "Denmark", "Denmark", "Denmark", "Denmark", 
"Denmark", "France", "France", "France", "France", "France", 
"France", "France", "France", "France", "France", "France", "France", 
"France", "France", "France", "France", "France", "France", "Germany", 
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany", 
"Germany", "Germany", "Germany", "Germany", "Germany", "Germany", 
"Germany", "Germany", "Germany", "Germany", "Germany", "India", 
"India", "India", "India", "India", "India", "India", "India", 
"India", "India", "India", "India", "India", "India", "India", 
"India", "India", "India", "Ireland", "Ireland", "Ireland", "Ireland", 
"Ireland", "Ireland", "Ireland", "Ireland", "Ireland", "Ireland", 
"Ireland", "Ireland", "Ireland", "Ireland", "Ireland", "Ireland", 
"Ireland", "Ireland"), X1 = c(3.27174899658596, 3.44673509450937, 
2.64395904378575, 1.58456730601224, 2.16743125018965, 3.31911583261663, 
2.23726956852264, 1.77511435202873, 3.65813969797517, 4.12844016828202, 
2.85816958611764, 4.56493519914533, 3.19629870897384, 3.8359860137505, 
1.73563059944581, 2.83162301549495, 2.8421173133526, 3.16123524600627, 
3.77678469352135, 2.52390700311155, 2.86703483251811, 1.4642422958704, 
2.44409949484033, 1.98382445946999, 2.08608161633344, 1.33717864018883, 
3.10661251556943, 2.59616035959905, 3.10293081410824, 2.55081972979485, 
2.93708642404458, 4.06958879549751, 3.46029141425962, 4.66548338294964, 
6.37236639349529, 3.8865176294302, 3.39189962902611, 5.07233659997997, 
3.39291328977728, 3.93313818780746, 4.07071524279786, 5.60983056039743, 
5.89762459633962, 8.77890979526038, 4.14933830958844, 3.03199580726918, 
4.38693661617511, 3.79558881760211, 5.17804550049788, 7.61373911835908, 
9.48282030466183, 8.12976927633705, 7.22116200525995, 4.47675128870693, 
1.43677820032231, 2.74853483526785, 2.56064220400959, 0.971283764503543, 
1.97481802206972, 2.58653099046437, 3.99736261429274, 2.03066750796093, 
1.20309689844021, 3.93344667010933, 4.01480409962075, 3.44116854517512, 
4.31180413415391, 2.34113815434215, 4.12656069659063, 4.6372470328762, 
2.00913378495256, 2.7483063878531, 3.87248389945754, 2.67774149200003, 
5.2796102225175, 4.80727076074593, 2.73767566975494, 4.27732694868552, 
5.85566302492039, 5.79182322384288, 3.55068864977317, 4.64860169464781, 
4.9801069786268, 4.60292481782356, 4.87290868636334, 4.20978397849308, 
6.95050573279854, 9.68051337031469, 8.66370192377599, 4.230741987564, 
3.07982828150325, 4.03906962209736, 3.5823083572545, 4.91414184426599, 
3.71105317895875, 2.9601146363461, 4.96537519190897, 7.89681729437025, 
3.90596888781504, 5.7650255624365, 2.82697565332194, 3.14435762098616, 
4.28490807009774, 3.85830855322677, 4.77472277464291, 6.38828546365713, 
5.53267491935278, 3.01893835228592, 1.12102923761859, 2.04469175260899, 
3.44144623726794, 1.25480368327704, 2.24762712924279, 5.08453313524742, 
2.68805688331258, 1.76739802010282, 4.17799056951915, -1.42262741218997, 
8.00397857969829, 5.98100865226862, 8.71810201149444, 8.67712749955659, 
5.54223272061643, 7.37351873948889, 12.885179886192, 9.70839771473518, 
1.53653083687676, 2.77123923288968, 2.12130223816759, 2.47037959859437, 
3.18314899371355, 3.57788212058471, 3.97245800993785, 2.27476156545043, 
2.91019972995579, 3.0271599406126, 3.25133163598937, 6.82422290936298, 
6.62648597410127, 7.53567054817564, 8.6272902729506, 3.41816288854943, 
2.3249344836575, 2.25726681039224), X2 = c("11.08", "12.1", "16.3", 
"14.92", "13.64", "12.69", "12.24", "11.62", "8.4499999999999993", 
"7.56", "10.82", "13.72", "22.24", "29.74", "20.54", "15.83", 
"17.59", "12.76", "13.73", "14.05", "21.12", "23.81", "17.59", 
"14.71", "14.34", "14.34", "13.41", "14.07", "16.82", "20.149999999999999", 
"26.86", "46.82", "35.31", "24.42", "28.52", "21.65", "NA", "NA", 
"16.690000000000001", "21.77", "19.12", "14.25", "17.75", "26.06", 
"15.76", "8.93", "10.01", "12.87", "20.86", "33", "23.28", "19.079999999999998", 
"20.27", "15.49", "10.199999999999999", "11.6", "18.03", "21.25", 
"18.850000000000001", "20.45", "21.35", "23.9", "16.940000000000001", 
"12.41", "14.42", "15.96", "23.17", "37.07", "26.53", "19.5", 
"20.61", "16.61", "16.05", "16.18", "22.58", "25.68", "21.97", 
"23.28", "28.24", "35.06", "21.55", "12.79", "12.88", "15.14", 
"23.52", "37.94", "27.79", "23.46", "27.36", "20.78", "11.73", 
"14.82", "23.28", "26.72", "22.59", "22.95", "28.89", "38.08", 
"25.24", "14.13", "13.64", "15.48", "21.95", "36.119999999999997", 
"26.73", "20.440000000000001", "26.6", "18.55", "21.26", "25.82", 
"27.19", "30.46", "32.58", "31.85", "24.37", "17.93", "23.17", 
"21.88", "20.85", "25.07", "31.23", "43.74", "30.35", "17.940000000000001", 
"19.54", "15.81", "8.94", "10.11", "16.52", "21.79", "18.13", 
"18.14", "20.27", "20.76", "14.25", "12.18", "12.54", "16.47", 
"30.26", "45.66", "31.72", "23.82", "21.75", "15.85")), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -144L), .Names = c("t", 
"id", "X1", "X2"))

原因是 X2 被视为字符向量而不是数字向量:

str(data$X2)
 chr [1:144] "11.08" "12.1" "16.3" "14.92" "13.64" "12.69" "12.24" "11.62" ...

添加

data$X2 <- as.numeric(data$X2)

开头的某处修复了问题并给出了

Coefficients:
            Estimate Std. Error t-value  Pr(>|t|)    
(Intercept) 2.066039   0.491482  4.2037 4.657e-05 ***
X2          0.096819   0.022337  4.3345 2.773e-05 ***