R中多项式的拟合值太短

时间:2014-09-24 19:54:31

标签: r short predict

晚上有点简单的问题......

我得到了模型及其边际效应。

library(mlogit)
library(plm)
pdata<-plm.data(data,index=c("ID","time"))
mldata<-mlogit.data(pdata,choice="ERA",shape="wide")
mlogit.data2<-mlogit(ERA~1|CHINN+INFL+MONEY+OPENNESS+RGDP+RSVS,data=mldata,reflevel="2")
summary(mlogit.data2)

现在我想看看我的模型的拟合值,但是我得到一个错误:

> mldata$fitted <- fitted(mlogit.data2,data=mldata)
Error in `[[<-.data.frame`(object, x, value = value) : 
  replacement has 189 rows, data has 3534

为什么R不计算我所有数据行的拟合值?有可能克服这个问题吗? 在?fitted我找不到多少帮助。

此外,mlogit包装说明并没有帮助。建议的解决方案提供相同的错误消息:

> mldata$fitted <- fitted(mlogit.data2,outcome=TRUE)
Error in `[[<-.data.frame`(object, x, value = value) : 
  replacement has 189 rows, data has 3534

PS。数据样本(原始数据有589个观察结果):

> dput(data)
structure(list(ID = c("POL", "POL", "POL", "POL", "POL", "POL", 
"POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", "POL", 
"POL", "POL", "POL", "POL", "BGR", "BGR", "BGR", "BGR", "BGR", 
"BGR", "BGR", "BGR", "BGR", "BGR", "BGR", "BGR", "BGR", "BGR", 
"BGR", "BGR", "BGR", "BGR", "BGR", "CYP", "CYP", "CYP", "CYP", 
"CYP", "CYP", "CYP", "CYP", "CYP", "CYP", "CYP", "CYP", "CYP", 
"CYP", "CYP", "CYP", "CYP", "CYP", "CYP", "CZE", "CZE", "CZE", 
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", 
"CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "CZE", "EST", "EST", 
"EST", "EST", "EST", "EST", "EST", "EST", "EST", "EST", "EST", 
"EST", "EST", "EST", "EST", "EST", "EST", "EST", "EST", "SVN", 
"SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", 
"SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", "SVN", 
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", 
"SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", "SVK", 
"SVK", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", 
"ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", "ROM", 
"ROM", "ROM", "MLT", "MLT", "MLT", "MLT", "MLT", "MLT", "MLT", 
"MLT", "MLT", "MLT", "MLT", "MLT", "MLT", "MLT", "MLT", "MLT", 
"MLT", "MLT", "MLT", "LVA", "LVA", "LVA", "LVA", "LVA", "LVA", 
"LVA", "LVA", "LVA", "LVA", "LVA", "LVA", "LVA", "LVA", "LVA", 
"LVA", "LVA", "LVA", "LVA", "LTU", "LTU", "LTU", "LTU", "LTU", 
"LTU", "LTU", "LTU", "LTU", "LTU"), time = c(1993L, 1994L, 1995L, 
1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 1993L, 1994L, 
1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 1993L, 
1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 
2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 
1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 
2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 
2011L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 
2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 
2010L, 2011L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 1999L, 
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L, 
2009L, 2010L, 2011L, 1993L, 1994L, 1995L, 1996L, 1997L, 1998L, 
1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 
2008L, 2009L, 2010L, 2011L, 1993L, 1994L, 1995L, 1996L, 1997L, 
1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 
2007L, 2008L, 2009L, 2010L, 2011L, 1993L, 1994L, 1995L, 1996L, 
1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 
2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 1993L, 1994L, 1995L, 
1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L, 2003L, 2004L, 
2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 1993L, 1994L, 
1995L, 1996L, 1997L, 1998L, 1999L, 2000L, 2001L, 2002L), CHINN = c(-1.863972, 
-0.8081098, -0.1129656, -1.168828, -1.168828, -1.168828, -1.168828, 
-1.168828, -1.168828, 0.0644257, 0.0644257, 0.0644257, 0.0644257, 
0.0644257, 0.0644257, 0.0644257, 0.0644257, 0.0644257, 0.0644257, 
NA, -1.168828, -1.168828, -0.905084, -0.905084, -0.905084, -0.905084, 
-0.905084, -1.168828, -1.168828, -0.905084, -0.6413398, -0.3775955, 
2.175265, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, -0.1129656, 
-0.1129656, -0.1129656, -1.168828, -1.168828, -1.168828, -1.168828, 
-1.168828, -1.168828, -1.168828, -0.1129656, 1.384032, 1.647777, 
1.911521, 2.175265, 2.439009, 2.439009, 2.439009, 2.439009, NA, 
NA, NA, -0.1129656, -0.1129656, -0.1129656, -0.1129656, 0.1507786, 
1.647777, 1.911521, 2.175265, 2.439009, 2.439009, 2.439009, 2.439009, 
2.439009, 2.439009, 2.439009, 2.439009, NA, NA, NA, 1.911521, 
2.175265, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 
2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 
2.439009, NA, NA, NA, -1.168828, -0.1129656, -0.1129656, -0.1129656, 
1.120288, 1.120288, 1.120288, 1.384032, 1.647777, 1.911521, 2.175265, 
2.439009, 2.175265, 1.911521, 1.647777, 1.384032, NA, NA, NA, 
-1.168828, -1.168828, -1.168828, -1.168828, -1.168828, -1.168828, 
-1.168828, 0.0644257, 0.0644257, 0.3281699, 0.5919141, 0.8556583, 
1.119403, 1.383147, 1.383147, 1.383147, -1.863972, -1.863972, 
-1.863972, -1.168828, -1.168828, -1.168828, -1.168828, -1.168828, 
-1.168828, 0.0644257, 0.3281699, 1.647777, 1.911521, 2.175265, 
2.439009, 2.439009, 2.439009, 2.439009, 2.439009, -1.168828, 
-0.1129656, -0.8081098, -1.168828, -1.168828, -1.168828, -1.168828, 
-1.168828, -1.168828, -1.168828, -1.168828, 0.3281699, 1.647777, 
1.911521, 2.175265, 2.439009, 2.439009, 2.439009, 2.439009, NA, 
NA, NA, 1.911521, 2.175265, 2.175265, 2.175265, 2.175265, 2.175265, 
2.175265, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 2.439009, 
2.439009, 2.439009, 2.439009, NA, NA, NA, 2.175265, 2.439009, 
2.439009, 2.439009, 2.439009, 2.439009, 2.439009), DEBT = c(NA, 
NA, NA, NA, NA, NA, NA, 32.96342571, 41.3785683, 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, 13.82140101, 14.93887326, 15.44619896, 
NA, NA, NA, NA, NA, 261.728718, 155.7574546, 156.2502269, 160.8780718, 
170.5201125, 179.1116438, 180.2266059, 180.5662061, 171.3756799, 
96.7356357, 144.1937256, 97.56739053, 102.2997423, 113.2526569, 
16.48781937, 14.67202387, 12.70783399, 10.52030143, 10.15356587, 
10.17878009, 11.35669558, 13.21886861, 14.87443421, 15.42556465, 
18.26772521, 20.10837875, 22.03346153, 23.70805456, 24.19331983, 
25.47516365, 30.87178726, 34.99728295, 38.2537664, NA, NA, 9.875827385, 
8.8766474, 8.42058185, 4.139266952, 5.505295373, 4.302063581, 
4.095615556, 4.817197751, 5.233459351, 5.473257561, 5.864024828, 
5.535902971, 4.81287326, 5.66674747, 8.950785028, 9.109930881, 
6.942970339, 21.12055362, 18.51055365, 16.84588811, 20.28397162, 
20.91442134, 21.48695465, 22.02828204, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
45.37393175, 44.85614255, 37.1317334, 32.91680584, 31.91610243, 
30.2380593, 38.24368205, 46.55843081, 45.6102019, 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, 185.1302222, 192.8527028, 
193.5122253, 178.2882862, 170.9141325, 75.8456974, 81.9356132, 
82.94168669, 84.04041655, NA, 11.19069767, 14.58974458, 13.26744904, 
10.99750203, 9.54700351, 11.97419745, 12.01682427, 13.65810559, 
NA, NA, NA, NA, NA, NA, 22.89317326, 42.16345422, 49.88284724, 
42.12534325, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), ERA = structure(c(1L, 
1L, 1L, 1L, 1L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 5L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 5L, 5L, 5L, 5L, 1L, 3L, 3L, 3L, 
2L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 1L, 1L, 
1L, 1L, 1L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 6L, 6L, 6L, 6L, 
6L, 5L, 5L, 5L, 5L, 5L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 6L, 6L, 6L, 2L, 2L, 2L, 2L, 1L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 2L, 2L, 5L, 5L, 5L, 5L, 
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 2L, 5L, 5L, 
5L, 5L, 6L, 6L, 6L, 6L, 6L), .Label = c("0", "1", "2", "4", "5", 
"6"), class = "factor"), INFL = c(32.88153432, 30.75869771, 26.06227768, 
19.17945154, 14.8181395, 11.13536692, 7.083028472, 10.73214358, 
4.365764296, 0.468914489, -0.309213178, 2.505644136, 1.488838798, 
0.802931491, 0.757724135, 3.575611747, 2.645957976, 1.673380405, 
3.027484539, 68.89452067, 93.56390749, 60.04541489, 120.9697303, 
1058.110374, 18.08247302, 2.381037536, 10.98858826, 6.23546693, 
4.378871042, 1.059975277, 5.275230048, 4.420631575, 6.949600859, 
6.772151187, 11.5750056, 1.573166761, 1.404937188, 2.989021435, 
0.869895952, 2.205158532, 0.606399087, 2.341155169, 3.341867083, 
1.637920558, 1.438028472, 4.813986108, 0.851572796, 1.369895581, 
3.041933627, 1.215313972, 1.940240026, 2.183862478, 0.742157177, 
3.895404593, -0.805939925, 1.347186409, 2.058600601, NA, 7.470554816, 
7.160886884, 8.162230304, 8.284316757, 10.03680087, 1.951158973, 
4.57516348, 3.580328061, 0.353839829, -0.989422969, 1.756368044, 
1.227958743, 2.216092544, 1.297107905, 5.5772198, -0.135208014, 
0.37464597, 0.705540354, 85.82767831, 45.16125984, 26.76719493, 
22.41257365, 10.31840157, 7.618546565, 3.104139369, 4.69827344, 
4.613783954, 2.140023859, 0.241157716, 1.977168612, 3.471477961, 
4.117902416, 4.967303028, 9.59183654, -1.264796394, 1.941508375, 
3.746765989, 28.87406262, 18.50010871, 11.45351537, 9.15451517, 
8.098292364, 7.323560048, 5.957481952, 9.551132139, 7.297001041, 
6.038828058, 4.4816701, 2.5181237, 1.859242437, 2.150549111, 
1.980829766, 4.878079781, -0.324099786, 0.806893393, 0.579731127, 
NA, 10.9167027, 7.877750089, 5.171485258, 5.846056108, 6.108485138, 
10.37847422, 12.70810524, 6.204147329, 1.892051179, 7.457011294, 
6.477597786, 2.090872986, 4.171318751, 1.12638815, 3.824413275, 
0.43508474, -0.077053821, 2.688437197, 251.1825911, 134.265962, 
30.23306593, 38.19153164, 154.5000031, 58.50679599, 45.6118096, 
46.33892251, 33.34228373, 21.10595053, 14.17683938, 10.80596477, 
8.370844841, 6.27257596, 3.205443818, 7.074558656, 4.407643597, 
5.060143833, 4.556928586, 0.160548827, 1.636491038, 2.41722671, 
1.416230304, 2.848600559, 1.795464586, 1.94279736, 3.041921336, 
1.804008857, 0.75723101, 0.206706014, 1.719925385, 2.389754565, 
2.461251718, -0.37898616, 3.482970458, 0.905337431, 0.482761812, 
1.491056375, 104.7834598, 33.43166158, 22.97001407, 16.97350899, 
8.174354733, 4.068517165, 2.166871465, 3.320920745, 1.353183622, 
0.491817452, 1.859491465, 5.116514248, 6.124960356, 6.22186537, 
8.476838023, 14.62943067, 2.347653559, -2.12232124, 3.152004569, 
406.256717, 69.65670824, 37.64737798, 23.9803578, 8.614412981, 
4.485147531, 0.561737871, 1.679115791, 0.229651367, -1.13291693
), MONEY = c(33.47353185, 31.98627557, 31.69277212, 33.19737536, 
35.11881075, 37.70207735, 40.69940688, 40.60334482, 44.4362372, 
41.98616138, 42.4262879, 40.21143533, 43.50525068, 46.92579745, 
47.82156081, 52.36351657, 53.71374196, 55.42878357, 57.87980215, 
78.96788223, 79.70281583, 67.02978372, 83.30492066, 35.17443875, 
28.90920096, 30.99875517, 35.97481045, 40.92721065, 41.75303846, 
46.25983651, 51.21172707, 55.53534932, 61.91482825, 69.93832611, 
66.12313685, 69.86326874, 71.96151683, 75.58550182, 129.3675757, 
131.4806475, 128.6485046, 136.9487074, 145.3864396, 147.0066966, 
159.3015, 161.2947176, 169.5276212, 175.6224217, 174.5080264, 
171.4267582, 176.9652918, 189.8620473, 206.7065572, NA, NA, NA, 
NA, 60.92063478, 63.44783757, 70.78822385, 65.59993188, 62.32748907, 
58.90282855, 57.98895591, 63.69128011, 65.63634827, 55.65605855, 
56.64938189, 55.81345513, 58.23563505, 61.13655108, 64.9819949, 
70.24647315, 72.07127255, 72.80557549, 74.20307208, NA, NA, 16.28198341, 
18.59581587, 22.64679373, 21.32290822, 24.66368542, 27.98839916, 
31.03625086, 31.54308533, 31.64045263, 57.85539671, 62.89230872, 
61.42038589, 56.4714398, 56.99786929, 60.17466759, 59.63639818, 
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
NA, NA, NA, NA, 61.15405566, 59.60914754, 60.66020951, 63.23684312, 
61.9963394, 59.33261741, 61.66891001, 64.03492616, 66.55383486, 
63.50001349, 54.86765959, 56.68681216, 54.68544393, 56.32768785, 
56.87940867, 54.92974214, NA, NA, NA, 28.79255586, 26.12976897, 
30.58119755, 34.33863042, 31.56100706, 32.83360067, 33.82383876, 
32.33703427, 26.27066873, 29.68805324, 27.55867111, 32.79993702, 
33.65938723, 32.13648505, 35.89669667, 33.82315729, 37.87642747, 
38.80005701, 37.31145552, 97.77683268, 106.1592034, 110.2402478, 
116.4126078, 120.6724805, 125.3530212, 131.8760714, 123.5668284, 
156.0884931, 163.0033367, 161.1434804, 150.6851493, 147.5321398, 
147.6344025, 152.1430848, NA, NA, NA, NA, 31.6473756, 34.17121175, 
21.27219875, 21.33064595, 25.22756743, 24.56809039, 24.33920343, 
27.75907666, 30.26917736, 32.91405053, 34.77361485, 37.87769754, 
43.32659977, 49.26778617, 42.70014296, 37.29869945, 44.89101908, 
51.41357898, 46.66134275, 23.06471096, 25.77555608, 20.86731738, 
16.09189946, 17.94874959, 18.49845167, 20.44411024, 22.86014763, 
26.19698213, 28.50868349), OPENNESS = c(41.05223192, 41.26984163, 
44.2465201, 46.04792205, 50.74269481, 56.79411951, 54.29510521, 
60.67078823, 57.77678292, 60.73279263, 69.31848911, 77.33549081, 
74.91126836, 82.51673772, 84.38852522, 83.76331224, 78.80572562, 
85.68773797, 91.29238718, 84.04148545, 90.72012785, 101.8271665, 
116.1971199, 112.0938612, 117.1780783, 116.5593551, 106.2621055, 
106.8660521, 102.9803349, 107.3846266, 115.3229367, 96.16403889, 
140.00543, 138.6499918, 136.949385, 103.8483695, 116.7151556, 
132.2741747, 95.41637402, 95.77615252, 100.1037057, 104.4416258, 
105.3995874, 100.5282431, 101.757892, 109.8712906, 109.9020613, 
103.0649958, 95.17382146, 98.02155335, 99.20612861, 99.76019554, 
102.1400302, 101.6254989, 85.82792399, 86.67220155, NA, 94.12769898, 
90.04033769, 99.78698239, 98.18406823, 104.0736921, 105.0109552, 
107.2165817, 124.0086884, 126.7486932, 116.447208, 119.381669, 
125.0827196, 126.1367896, 130.9370432, 133.7710948, 126.5060567, 
113.8718253, 129.8170346, 141.6332736, NA, NA, 143.7179084, 134.7434335, 
154.3553107, 159.1496939, 145.7897864, 172.7948897, 162.1300543, 
149.2192177, 145.8703769, 153.2040725, 161.9353192, 155.6454263, 
143.3739112, 146.1357753, 122.2064814, 151.5067996, 177.3375262, 
116.4165437, 115.2014835, 101.1237517, 100.776851, 103.4629999, 
103.6353427, 98.64583785, 110.8680986, 111.1888697, 108.9876134, 
107.8240756, 116.9086478, 124.764116, 133.598327, 140.8368678, 
137.5052976, 115.3428892, 130.2847534, 141.5175657, 116.9348272, 
113.2022693, 113.3092331, 117.4438733, 122.3418682, 129.1833372, 
126.8180934, 143.4736581, 153.5098819, 149.5165658, 153.6020099, 
151.8684993, 157.1687775, 173.0136412, 174.8163254, 169.3228654, 
142.5879841, 163.8001325, 175.7176224, 51.00369936, 51.86707001, 
60.82927135, 64.71002465, 65.41719447, 53.27005779, 60.86839403, 
70.5914681, 74.46352454, 76.4830536, 76.89638869, 80.96167927, 
76.20539448, 68.18852263, 73.57621774, 73.90188459, 67.24366514, 
76.18112026, 81.8362363, 178.9054338, 181.7019463, 179.3338738, 
167.8851768, 160.4646891, 163.2107217, 171.0564001, 188.9774697, 
163.0670335, 162.3427202, 157.3654611, 159.0125582, 156.7217471, 
177.5077845, 180.7941193, 177.0591459, 157.7877639, 172.9496893, 
185.5022935, 130.2181322, 90.8494492, 87.5469943, 101.0662852, 
101.5015858, 106.7975095, 89.9670903, 90.31615179, 92.68561261, 
91.49535672, 96.71695153, 103.5328216, 110.0826793, 111.2338429, 
104.726441, 99.28055145, 89.25447506, 109.047353, 121.5114324, 
172.9016402, 116.7723585, 105.3835898, 109.1377282, 113.1588949, 
101.4645839, 87.27803033, 95.76970842, 105.0877009, 111.1276913
), RESERVES = c(4276726138, 6023061884, 14957024390, 18018686050, 
20669498248, 28276350644, 27314254555, 27469379821, 26563086922, 
29783861006, 33958963841, 36772764782, 42560657450, 48473947849, 
65724834811, 62183606786, 79521598778, 93472496388, 97712443397, 
1052450357, 1396927258, 1635188166, 864262494.1, 2485359931, 
3056954172, 3264673405, 3507199103, 3646131855, 4846429828, 6825720096, 
9337108247, 8697081229, 11756001804, 17544560083, 17930378450, 
18522120691, 17223201500, 17215734344, 1276350873, 1640273818, 
1294935266, 1704484151, 1525648570, 1512684182, 1967461070, 1868515552, 
2396061109, 3181358048, 3450932640, 4113824175, 4429824674, 5942554106, 
6506542509, 1004746555, 1281245174, 1141718168, 1187123277, 4551181369, 
6948563350, 14612514155, 13084766355, 10035803026, 12624991439, 
12935556426, 13141569753, 14463996079, 23707070645, 26955067756, 
28451131839, 29553533244, 31456871115, 34907225421, 37021635007, 
41608025194, 42482656052, 40283021631, 389247606.4, 446418562, 
583006267.3, 639770387.4, 760039371.1, 812906422.9, 855813707.1, 
922839655.6, 822453577.7, 1003157301, 1376698670, 1791730277, 
1947311947, 2786325227, 3269362368, 3971834389, 3980640980, 2567137793, 
207115954.6, 787924762, 1499101326, 1820915561, 2297475330, 3314759606, 
3638608389, 3168097481, 3196099289, 4397212845, 7063482326, 8598243614, 
8899759253, 8159730205, 7139432938, 1065303830, 957648198.5, 
1078161476, 1070759591, 986894540.6, 919587371.3, 2185568839, 
3862773676, 3895192648, 3604685659, 3240043067, 3745098698, 4376328678, 
4453132136, 9195618257, 12149157812, 14911965835, 15479863363, 
13364307417, 18973379157, 18836137106, 1803646824, 2155731815, 
2417987711, 1921318133, 3092362958, 2624348247, 3143305792, 4679435834, 
3795239432, 2490772917, 3395672577, 4857637362, 7285846575, 9449445049, 
16095478769, 21601177537, 30206004058, 39974195970, 39768375717, 
44383053416, 48047827695, 48044370164, 1401663051, 1890025826, 
1620329964, 1636087069, 1490757865, 1664438098, 1789768390, 1471281954, 
1667548395, 2210545483, 2730176861, 2733736253, 2578481095, 2980332941, 
3798767206, 373422746.2, 538508822.1, 540153472.9, 515098490.9, 
526398174.9, 640693740.8, 602076781.1, 746119791.7, 832492439.1, 
872976183.8, 944355642.8, 919162856.4, 1217482763, 1326623372, 
1536170568, 2020863044, 2359714950, 4511469902, 5760724076, 5243938989, 
6902262629, 7605712549, 6378031619, 422943421.4, 596691631.7, 
828984764.7, 841037164.5, 1064038330, 1462691472, 1249084970, 
1362679202, 1669177344, 2413140588), RGDP = c(100, 105.1391162, 
112.1509073, 119.005788, 127.4353042, 133.6559672, 139.7422509, 
145.6660621, 147.2589562, 149.3246384, 154.9589508, 162.9841136, 
168.5495612, 178.8365585, 190.5332595, 199.8346506, 203.4038506, 
211.5010309, 220.7118885, 100, 101.9220658, 104.4839149, 95.38304238, 
93.68869235, 97.96298561, 99.87454727, 105.591921, 109.9478097, 
114.9480326, 120.9328675, 128.7653354, 136.8223682, 145.511543, 
154.4341179, 163.6529144, 154.7548279, 155.4006564, 158.0084556, 
100, 105.7732358, 111.9655264, 114.0238994, 116.7555866, 122.5589293, 
128.4705687, 135.0097041, 140.3917784, 143.2003453, 145.5952779, 
151.4732402, 157.2827045, 163.6380516, 171.731247, 177.6856887, 
174.8499881, 177.1535033, 177.7304866, 100, 102.7384259, 108.8661742, 
113.6744545, 112.800479, 112.4508441, 114.3691083, 119.2179873, 
122.797706, 125.1689911, 129.613866, 135.5067855, 144.4656901, 
154.404532, 162.9250334, 167.5684875, 160.2257716, 164.1720313, 
167.012634, 100, 98.33018528, 102.6444758, 108.601421, 121.273949, 
129.4007604, 129.0250041, 141.5434932, 150.2939865, 159.8927763, 
171.758774, 182.2717478, 198.1257125, 217.7171012, 233.357799, 
223.4830762, 192.3837255, 197.3551291, 215.8558129, 100, 105.1923608, 
108.5446975, 112.4932731, 118.1087505, 122.1834182, 128.6588444, 
134.2812096, 138.1936725, 143.3043358, 147.1306159, 153.3705352, 
159.4312742, 168.61331, 179.835345, 186.0126753, 171.3060965, 
173.7443344, 174.8367644, 100, 105.9850636, 111.8798773, 119.555904, 
124.8768061, 130.2192072, 130.238572, 132.0739711, 136.5994492, 
142.6650389, 149.0160745, 156.2202527, 166.4706386, 180.1549983, 
198.6659387, 209.7642126, 199.6480942, 208.002889, 214.0327668, 
100, 103.8294308, 111.0769249, 115.5343789, 108.4851391, 103.0797459, 
102.0024424, 104.0954101, 109.9164505, 115.3025274, 120.9076396, 
131.6083962, 136.8467152, 148.4500493, 157.1627855, 169.2078376, 
158.0349691, 156.5456772, 159.9909251, 100, 105.5443176, 112.0268514, 
116.2360297, 122.3586774, 128.5709767, 134.6063067, 143.7023749, 
141.4895995, 145.3309889, 145.2443933, 144.3648557, 149.5704219, 
152.7943616, 159.0640885, 165.7847042, 161.4752791, 165.841231, 
168.6256794, 100, 102.0572195, 101.0577598, 104.8212893, 113.4005829, 
118.6668018, 124.1226224, 132.6116153, 143.1969698, 152.2928709, 
162.9457634, 176.7107661, 195.1509122, 218.5505621, 239.3885729, 
228.8219076, 188.2666115, 187.7556825, 197.3571282, 100, 90.29670704, 
93.14475261, 97.91066445, 105.0259765, 112.9215268, 111.7379785, 
115.3231334, 123.0178451, 131.2583795), RSVS = c(4.276726138, 
6.023061884, 14.95702439, 18.01868605, 20.669498248, 28.276350644, 
27.314254555, 27.469379821, 26.563086922, 29.783861006, 33.958963841, 
36.772764782, 42.56065745, 48.473947849, 65.724834811, 62.183606786, 
79.521598778, 93.472496388, 97.712443397, 1.052450357, 1.396927258, 
1.635188166, 0.8642624941, 2.485359931, 3.056954172, 3.264673405, 
3.507199103, 3.646131855, 4.846429828, 6.825720096, 9.337108247, 
8.697081229, 11.756001804, 17.544560083, 17.93037845, 18.522120691, 
17.2232015, 17.215734344, 1.276350873, 1.640273818, 1.294935266, 
1.704484151, 1.52564857, 1.512684182, 1.96746107, 1.868515552, 
2.396061109, 3.181358048, 3.45093264, 4.113824175, 4.429824674, 
5.942554106, 6.506542509, 1.004746555, 1.281245174, 1.141718168, 
1.187123277, 4.551181369, 6.94856335, 14.612514155, 13.084766355, 
10.035803026, 12.624991439, 12.935556426, 13.141569753, 14.463996079, 
23.707070645, 26.955067756, 28.451131839, 29.553533244, 31.456871115, 
34.907225421, 37.021635007, 41.608025194, 42.482656052, 40.283021631, 
0.3892476064, 0.446418562, 0.5830062673, 0.6397703874, 0.7600393711, 
0.8129064229, 0.8558137071, 0.9228396556, 0.8224535777, 1.003157301, 
1.37669867, 1.791730277, 1.947311947, 2.786325227, 3.269362368, 
3.971834389, 3.98064098, 2.567137793, 0.2071159546, 0.787924762, 
1.499101326, 1.820915561, 2.29747533, 3.314759606, 3.638608389, 
3.168097481, 3.196099289, 4.397212845, 7.063482326, 8.598243614, 
8.899759253, 8.159730205, 7.139432938, 1.06530383, 0.9576481985, 
1.078161476, 1.070759591, 0.9868945406, 0.9195873713, 2.185568839, 
3.862773676, 3.895192648, 3.604685659, 3.240043067, 3.745098698, 
4.376328678, 4.453132136, 9.195618257, 12.149157812, 14.911965835, 
15.479863363, 13.364307417, 18.973379157, 18.836137106, 1.803646824, 
2.155731815, 2.417987711, 1.921318133, 3.092362958, 2.624348247, 
3.143305792, 4.679435834, 3.795239432, 2.490772917, 3.395672577, 
4.857637362, 7.285846575, 9.449445049, 16.095478769, 21.601177537, 
30.206004058, 39.97419597, 39.768375717, 44.383053416, 48.047827695, 
48.044370164, 1.401663051, 1.890025826, 1.620329964, 1.636087069, 
1.490757865, 1.664438098, 1.78976839, 1.471281954, 1.667548395, 
2.210545483, 2.730176861, 2.733736253, 2.578481095, 2.980332941, 
3.798767206, 0.3734227462, 0.5385088221, 0.5401534729, 0.5150984909, 
0.5263981749, 0.6406937408, 0.6020767811, 0.7461197917, 0.8324924391, 
0.8729761838, 0.9443556428, 0.9191628564, 1.217482763, 1.326623372, 
1.536170568, 2.020863044, 2.35971495, 4.511469902, 5.760724076, 
5.243938989, 6.902262629, 7.605712549, 6.378031619, 0.4229434214, 
0.5966916317, 0.8289847647, 0.8410371645, 1.06403833, 1.462691472, 
1.24908497, 1.362679202, 1.669177344, 2.413140588)), .Names = c("ID", 
"time", "CHINN", "DEBT", "ERA", "INFL", "MONEY", "OPENNESS", 
"RESERVES", "RGDP", "RSVS"), row.names = c(NA, 200L), class = "data.frame")

1 个答案:

答案 0 :(得分:0)

我认为你有两个问题,一个有NA个,一个有重复行。您将@ na.exclude设置为@aosmith建议或预先对数据运行na.omit()可能会处理此问题。

然后,如果仅查看模型中的列,fitted返回的值的数量就是唯一行的数量。

mldata <- na.omit(mldata)
mlogit.data2 <- mlogit(ERA~1|CHINN+INFL+MONEY+OPENNESS+RGDP+RSVS,data=mldata,reflevel="2")
summary(mlogit.data2)

dat.modeled <- mldata[, c("CHINN", "INFL", "MONEY", "OPENNESS", "RGDP", "RSVS")]
dat.undup <- dat.modeled[!duplicated(dat.modeled), ]

ft <- fitted(mlogit.data2)

> nrow(dat.undup)
[1] 67
> length(ft)
[1] 67

所以似乎fitted只是不想给你重复。 我建议改用predict。您可以相应地命名结果列,并使用merge添加将结果与原始数据相结合。

pr <- predict(mlogit.data2, newdata = mldata)