"non-finite value supplied by optim" 使用 betareg 时出错

"non-finite value supplied by optim" error when using betareg

我正在使用 包进行 beta 回归,但收到以下错误:

Error in optim(par = start, fn = loglikfun, gr = gradfun, method = method, : non-finite value supplied by optim

我可以将此错误追溯到为 optim 创建初始值。具体来说,betareg.fit 的这些行使用 lm.wfit 生成起始值。

事实证明,对于我的数据集,起始值之一返回为 NA。我不确定为什么会这样,因为 lm.wfit.

的数据/输入中没有缺失值

可复现例子看NA

## data -- a sample of 100 obs from my actual data
nobs <- 100L
w <- rep(1, nobs)
offset <- rep(0, nobs)
y <- stats::rbeta(nobs, 0.75, 1.658)
x <- structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.0165928242550604, 
0.0984749494334759, 0.05517578125, 0.0185352577155742, 0.168701442841287, 
0.0514759697487192, 0.026507054296708, 0.0188496858385694, 0.108620689655172, 
0.0722387772757858, 0.0272373540856031, 0.0538907902524382, 0.0295235311312482, 
0.0318257956448911, 0.231788079470199, 0.0674772036474164, 0.14846108458939, 
0.0969908238068386, 0.0441553321506012, 0.154121863799283, 0, 
0.110460389247421, 0.0292207792207792, 0.0522853185595568, 0.205288796102992, 
0.00961124552835874, 0.0546908714289824, 0.0268199233716475, 
0.0253164556962025, 0.181780542384243, 0.0551724137931034, 0.128842504743833, 
0.0751429349305745, 0.217853751187085, 0.0510314875135722, 0.108407709439207, 
0.04, 0.0638009815535624, 0.128329297820823, 0.0398115958281933, 
0.0513258247605534, 0.0520833333333333, 0.0956239870340357, 0.0742899497995351, 
0.144527098831031, 0.0723209169054441, 0.140116763969975, 0.172426847735821, 
0.00830471112933819, 0.0548386400835806, 0.0372010221576987, 
0.0549927641099855, 0.0386658431130327, 0.0256367439122648, 0.0166402535657686, 
0.0769230769230769, 0.0130681818181818, 0.0229684699649666, 0.0344827586206897, 
0.0135106607557526, 0.0581090909090909, 0.0321364452423698, 0.0141176470588235, 
0.0203003337041157, 0.0948080795499367, 0.0202898550724638, 0.0443828016643551, 
0.105830475257227, 0.0482315112540193, 0.0394736842105263, 0, 
0.071608040201005, 0.0416666666666667, 0.268330928934329, 0.0422895357985838, 
0.127678318597993, 0.037029330162505, 0.0328938677375888, 0.10183299389002, 
0.0628212450028555, 0.0283431291591781, 0.0690879300928454, 0.134792626728111, 
0.0770505385252693, 0.174605316421536, 0.0842012497997116, 0.068774108570891, 
0.137089781654799, 0.00986436498150432, 0.0812065297585365, 0.0904255319148936, 
0.0205776173285199, 0.0124064303568112, 0.0229630147033144, 0.0578925872983459, 
0.0709677419354839, 0.0640070144673389, 0.106259964391839, 0.0315146661646867, 
0.0356999429308195, 0.0268438884545218, 0.0748295057905382, 0.0556640625, 
0.021107943539976, 0.199778024417314, 0.0175652598194682, 0.0487387772552373, 
0.00289995166747221, 0.0672413793103448, 0.101364990868019, 0.0233463035019455, 
0.0732353773706287, 0.022508038585209, 0.0368509212730318, 0.101545253863135, 
0.0158054711246201, 0.152565574210159, 0.123442866663249, 0.0672186083185492, 
0.129032258064516, 0, 0.104565780781544, 0.0551948051948052, 
0.03601108033241, 0.160055671537926, 0.02201309207499, 0.0668891510112489, 
0.0421455938697318, 0.0632911392405063, 0.234027661399237, 0.0206896551724138, 
0.0950664136622391, 0.0936564116526001, 0.183475783475783, 0.0466883821932682, 
0.088748974363268, 0.0422641509433962, 0.0467084108986292, 0.0920096852300242, 
0.0401480318492767, 0.05103760198652, 0.0208333333333333, 0.0470016207455429, 
0.0887666928515318, 0.075451647183847, 0.0310601719197708, 0.0928685551212356, 
0.148991255923013, 0.0204541959296663, 0.0689569784090949, 0.0356901206750445, 
0.0680173661360347, 0.0508956145768993, 0.0320699343321964, 0.0293185419968304, 
0.0659340659340659, 0.00284090909090909, 0.0402373780415312, 
0, 0.0230103440996411, 0.0629090909090909, 0.0229802513464991, 
0, 0.00778642936596218, 0.0745676859521289, 0.0191304347826087, 
0.0443828016643551, 0.0975012248897599, 0.00964630225080386, 
0, 0, 0.0678391959798995, 0.05, 0.167973405256225, 0.0427812745869394, 
0.197810150080232, 0.0363158937772493, 0.0415070411371503, 0.109979633401222, 
0.0285551113649343, 0.0348520911254675, 0.0730930274895321, 0.119239631336406, 
0.087821043910522, 0.251855350155175, 0.0668162153501042, 0.0731018910527801, 
0.0945505662261226, 0.0530209617755857, 0.0879397164898608, 0.0531914893617021, 
0.0339350180505415, 0.0144171389279045, 0.0176020675444417, 0.0758627731264039, 
0.0387096774193548, 0.0791319596668128, 0.0898373582199164, 0.0641540015091306, 
0.0308596309526326, 0.0853097037616193, 0.145443642937691, 0.134765625, 
0.0735152424185233, 0.207547169811321, 0.0712368870456209, 0.1626763574177, 
0.0128081198646689, 0.096551724137931, 0.130923771988849, 0.0525291828793774, 
0.230005661202748, 0.0833089739842151, 0.123953098827471, 0.344370860927152, 
0.0419452887537994, 0.188428900927962, 0.237145640026657, 0.184407648334319, 
0.211469534050179, 0.0576923076923077, 0.182300929925301, 0.165584415584416, 
0.0806786703601108, 0.274298306657388, 0.0837699832267066, 0.137316953882448, 
0.157088122605364, 0.10126582278481, 0.260575112627044, 0.0413793103448276, 
0.198292220113852, 0.177511570922951, 0.296296296296296, 0.139522258414767, 
0.138297694201175, 0.0645283018867925, 0.12692502961584, 0.162227602905569, 
0.0730066165750813, 0.142559418233416, 0.239583333333333, 0.152350081037277, 
0.204935285553934, 0.155154091392136, 0.0889398280802292, 0.135152787965875, 
0.235552733134678, 0.0947352232531912, 0.154476512637182, 0.137157008940595, 
0.162083936324168, 0.138789376158122, 0.104513252539252, 0.0935023771790808, 
0.120879120879121, 0.0133522727272727, 0.0824038693376326, 0.0344827586206897, 
0.0789529237914292, 0.133527272727273, 0.0569120287253142, 0.0117647058823529, 
0.0233592880978865, 0.158352535758029, 0.0527536231884058, 0.104022191400832, 
0.201371876531112, 0.0289389067524116, 0.144736842105263, 0, 
0.10678391959799, 0.0583333333333333, 0.233080348742395, 0.127753737214791, 
0.233930088412044, 0.13375941339675, 0.13934317947634, 0.338085539714868, 
0.0805254140491148, 0.101811822995094, 0.167819649250561, 0.142857142857143, 
0.227009113504557, 0.254081770341384, 0.155103348822304, 0.161162856336438, 
0.124957303134607, 0.155363748458693, 0.214043708410037, 0.111702127659574, 
0.126714801444043, 0.0475465770701011, 0.195590169850639, 0.204512967122728, 
0.158064516129032, 0.306298407131375, 0.191432758458608, 0.179792327044226, 
0.072245355202807, 0.286421683606985, 0.19797912900281, 0.32275390625, 
0.4288140812333, 0.180910099889012, 0.165406196633325, 0.539974348011971, 
0.0396326727887869, 0.205172413793103, 0.528357204652504, 0.0953307392996109, 
0.456736831270425, 0.312189418298743, 0.440536013400335, 0.322295805739514, 
0.185410334346505, 0.289871801748646, 0.277182549853899, 0.478218016952494, 
0.186379928315412, 0.730769230769231, 0.312846181208395, 0.573051948051948, 
0.104916897506925, 0.251913709116214, 0.240451839867001, 0.390675796196668, 
0.314176245210728, 0.151898734177215, 0.321921116708234, 0.191379310344828, 
0.352371916508539, 0.384971413013885, 0.245204178537512, 0.314060803474484, 
0.177397478189521, 0.128301886792453, 0.418175664240988, 0.0532687651331719, 
0.263429404508243, 0.351343561546648, 0.520833333333333, 0.160453808752026, 
0.40037131675589, 0.0701381509032944, 0.139484240687679, 0.208627671654089, 
0.302720922280299, 0.464089813912954, 0.325967367919772, 0.509502256498519, 
0.357452966714906, 0.387770228536133, 0.389464763566684, 0.401743264659271, 
0.450549450549451, 0.0741477272727273, 0.371069078965643, 0.0344827586206897, 
0.351488283723876, 0.394836363636364, 0.10394973070018, 0.0164705882352941, 
0.0661846496106785, 0.247721658259119, 0.271552795031056, 0.375866851595007, 
0.326800587947085, 0.090032154340836, 0.302631578947368, 0, 0.293969849246231, 
0.0916666666666667, 0.262623094775136, 0.37765538945712, 0.437246326652613, 
0.553230281411019, 0.553700229860763, 0.327902240325866, 0.18275271273558, 
0.23291397483849, 0.407002852114813, 0.115207373271889, 0.569179784589892, 
0.306166509243017, 0.536532606954014, 0.426756985605419, 0.214233164297538, 
0.515413070283601, 0.401348069939186, 0.23936170212766, 0.406859205776173, 
0.301968017675986, 0.46031385697156, 0.417500510516643, 0.280645161290323, 
0.545082566125968, 0.308916785607088, 0.40121177121836, 0.110259770455074, 
0.573885848318999, 0.0979737591064492, 0.05517578125, 0.43828037308911, 
0, 0.0195169553549646, 0.106028217186832, 0.0224746254229096, 
0.0913793103448276, 0.149860617129674, 0.0214007782101167, 0.138210545276756, 
0.499269219526454, 0.351758793969849, 0, 0.0613981762917933, 
0.172457222550019, 0.257446045009484, 0.141730731322689, 0.129032258064516, 
0, 0.218723004217694, 0.116883116883117, 0.0207756232686981, 
0.00150777081883554, 0.598457747628731, 0.310768434074628, 0.0344827586206897, 
0.0759493670886076, 0, 0.0620689655172414, 0.0992409867172676, 
0.175878028859243, 0.0207027540360874, 0.342562432138979, 0.0380448433496877, 
0.0252830188679245, 0.138432898967676, 0, 0.510037007962319, 
0.150097552323519, 0.0520833333333333, 0, 0.200037592718361, 
0, 0.0220057306590258, 0.107599706582795, 0.0987006008499829, 
0.381862921002717, 0.310497634940381, 0.266713526509752, 0.221418234442836, 
0.376899320568252, 0.147387273053657, 0.412044374009509, 0.137362637362637, 
0.266761363636364, 0.482401647112941, 0, 0.496200126662445, 0.145890909090909, 
0.00933572710951526, 0, 0.000278086763070078, 0.0862344564156858, 
0.598343685300207, 0.208044382801664, 0.171974522292994, 0.0418006430868167, 
0.0921052631578947, 0, 0.268844221105528, 0.0333333333333333, 
0.0333061531706705, 0.330841856805665, 0, 0.228289734443123, 
0.226188274459035, 0.0712830957230143, 0.0177041690462593, 0.0492786710059746, 
0.246950664482068, 0.00576036866359447, 0.0306545153272577, 0, 
0.0744271751321904, 0.198701665255433, 0.268701227042224, 0.196054254007398, 
0.0790648033408067, 0.0531914893617021, 0.00144404332129964, 
0.620702802934266, 0.28496257232331, 0.197569940780069, 0.170967741935484, 
0, 0.0478844352441583, 0.210611453120438, 0.0129145441863414, 
0.000260620276257493, 0.208709971897542, 0.3251953125, 0.0114926544356481, 
0.194228634850166, 0.640644059526714, 0.0280034202650705, 0.885693571773804, 
0.313793103448276, 0.00884360280688263, 0.739299610894942, 0.0108913821054528, 
0.00380005846243788, 0, 0, 0.610942249240122, 0.0171968030896315, 
0, 0.0280898876404494, 0.100358422939068, 0.173076923076923, 
0.0244422988973017, 0.0227272727272727, 0.62292243767313, 0.0628624449083739, 
0.00386676364499993, 0.00405650335164993, 0.314176245210728, 
0.126582278481013, 0.000798493705700851, 0.581034482758621, 0.0829222011385199, 
0.0245031309556221, 0.00588793922127255, 0.0293159609120521, 
0.380448433496877, 0.353207547169811, 0.0531392790658318, 0.414043583535109, 
0.0632499719636649, 0.096842852075204, 0.0416666666666667, 0.494327390599676, 
0.00292230188016789, 0.476089266737513, 0.557478510028653, 0.113709215510918, 
0.0199428459772361, 0.00563900138411852, 0.0115416622646005, 
0.0101230399337831, 0.0419681620839363, 0.00197652872143298, 
0.164294749497994, 0.00475435816164818, 0.137362637362637, 0.584090909090909, 
0.000167333519259466, 0.885057471264368, 0.00401097741186405, 
0.109381818181818, 0.647935368043088, 0.948235294117647, 0.50139043381535, 
0.188100724502294, 0.00447204968944099, 0.105409153952843, 0.0264576188143067, 
0.765273311897106, 0.368421052631579, 0.841726618705036, 0.0766331658291457, 
0.241666666666667, 0.0153672458132096, 0.0698269079464988, 0.00169902148947551, 
0.00340864050733254, 0.00261565695262755, 0.0366598778004073, 
0.572815533980582, 0.430635838150289, 0.0247284422598459, 0.285714285714286, 
0.00165700082850041, 0.00580218593981919, 0.071062329754847, 
0.0487345940351868, 0.0753895267873565, 0.00986436498150432, 
0.0469890478271147, 0.340425531914894, 0.216967509025271, 7.16946330049502e-05, 
0.0013271400132714, 0.0275678987134981, 0.0806451612903226, 0.00146134736226801, 
0.0792675274278758, 0.0146813198032706, 0.472691340280273, 0.00295369646425159, 
0.1175738808241, 0.0419921875, 0.00405272515967538, 0.048834628190899, 
0.0239082703098317, 0.0611372381359555, 0.00894151764137264, 
0.0827586206896552, 0.00552725175430164, 0.0330739299610895, 
0.0168742441007694, 0.00701549254603917, 0.0100502512562814, 
0, 0.0115501519756839, 0.0167676876039264, 0, 0.0364675734279519, 
0.046594982078853, 0.0384615384615385, 0.0193480359774379, 0.0275974025974026, 
0.0647506925207756, 0.0440733008582695, 0.0107987353233683, 0.0128455939468915, 
0.10727969348659, 0.455696202531646, 0.000897073175540462, 0.0344827586206897, 
0.0244781783681214, 0.0400217805608494, 0.0260208926875594, 0.0282301845819761, 
0.0483765635727323, 0.295849056603774, 0.11034015907937, 0.150121065375303, 
0.00336436021083324, 0.101764810216389, 0.0416666666666667, 0.0502431118314425, 
0.0128435876929952, 0.0786397449521785, 0.065214899713467, 0.107117376930575, 
0.0130062038981974, 0.0127646485876865, 0.0243222483755186, 0.00109047672226346, 
0.0419681620839363, 0.00148239654107474, 0.0995579008011222, 
0.0182250396196513, 0.010989010989011, 0.0190340909090909, 0.000341111490123878, 
0.0114942528735632, 0.00960523538104285, 0.0609454545454545, 
0.108617594254937, 0.00941176470588235, 0.370689655172414, 0.0941230200743186, 
0.00919254658385093, 0.0527045769764216, 0.0416462518373346, 
0.0128617363344051, 0.0263157894736842, 0.100719424460432, 0.0628140703517588, 
0.383333333333333, 0.013861882958038, 0.00324547600314713, 0.00163609476764308, 
0.00522195798652398, 0.00245713228883194, 0.00814663951120163, 
0.0422615648201028, 0.0899839704667994, 0.00467261362946781, 
0.165898617511521, 0.00662800331400166, 0.00748886789906895, 
0.00480692196763339, 0.00997271615391853, 0.0314314616779211, 
0.0357583230579531, 0.0671742820918722, 0.0585106382978723, 0.193501805054152, 
0.000332402389386587, 0.00658331296056997, 0.00745354298550133, 
0.106451612903226, 0.00401870524623703, 0.120851102817492, 0.0428155973269565, 
0.222051954091015, 0.00773173486230562, 0.0590151610073926, 0.00927734375, 
0.00420172240819286, 0, 0.0102464015613564, 0.0269345874305259, 
0.00869985500241663, 0.0344827586206897, 0.00288378352398347, 
0.00778210116731518, 0.0201551684207818, 0.0423852674656533, 
0.0050251256281407, 0, 0.00547112462006079, 0.0142509252802661, 
0.00779207463987287, 0.019712201852947, 0.043010752688172, 0, 
0.0273133797449057, 0.00974025974025974, 0.0176592797783934, 
0, 0.0310305927058439, 0.022756696107483, 0.00383141762452107, 
0, 0, 0.0137931034482759, 0.0187855787476281, 0.0283147291042744, 
0.00455840455840456, 0.0485884907709012, 0.0202783033875316, 
0.0505660377358491, 0.0424775765781012, 0, 0.0069530111023887, 
0.055028378857751, 0.03125, 0, 0.0158332727475844, 0, 0.0234957020057307, 
0.0948079222645377, 0.00865859020077182, 0.0121494848003281, 
0.0493989553698703, 0.00252254856234439, 0.0520984081041968, 
0.0035206917850525, 0.0370753822968285, 0.0237717908082409, 0, 
0.0267045454545455, 0.000411111567901742, 0, 0.0232214481739498, 
0.0344, 0.0181328545780969, 0, 0.0100111234705228, 0.0560918394884889, 
0.0242650103519669, 0.0651872399445215, 0.0284174424301813, 0.00321543408360129, 
0.0263157894736842, 0.0575539568345324, 0.0515075376884422, 0.1, 
0.00545694034999686, 0.00560582218725413, 0, 0.00274474831549742, 
0.00129461808766414, 0.00610997963340122, 0.0125642490005711, 
0.032180502258707, 0.00664482068086656, 0.0305299539170507, 0, 
0, 0.00705015221919564, 0.0127951829899332, 0.0536469691794319, 
0.0246609124537608, 0.022233842142586, 0.0531914893617021, 0, 
0.00255493601254004, 0.0106578656328944, 0.0116397794568103, 
0.0935483870967742, 0, 0.0555500678330224, 0.0552188638129316, 
0.0432774619010378, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 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0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 
0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 
1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 
1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 
1, 1, 0), .Dim = c(100L, 35L), .Dimnames = list(c("2801", "2316", 
"382", "8062", "2687", "2731", "8019", "5652", "8429", "3479", 
"7753", "9001", "2188", "8121", "8478", "5817", "1528", "2460", 
"3946", "3531", "3421", "2802", "1975", "3639", "2894", "5897", 
"9331", "9490", "7135", "5858", "7724", "9414", "9095", "6601", 
"5064", "7111", "3593", "7322", "9522", "7116", "6922", "5172", 
"2458", "5199", "1387", "3878", "6119", "8722", "6378", "4661", 
"6109", "3682", "5751", "9390", "7915", "5268", "1029", "5953", 
"242", "2912", "8798", "9607", "9768", "2222", "8260", "851", 
"4205", "1823", "5063", "4189", "7541", "608", "6849", "7220", 
"2889", "6770", "7064", "646", "4919", "1404", "120", "9716", 
"7722", "7700", "6638", "8176", "5745", "6", "9481", "2233", 
"341", "228", "1543", "553", "9709", "9493", "881", "7647", "6039", 
"2925"), c("(Intercept)", "x 1", "x 2", "x 3", "x 4", "x 5", 
"x 6", "x 7", "x 8", "x 9", "x 10", "x 11", "x 12", "x 13", "x 14", 
"x 15", "x 16", "x 17", "x 18", "x 19", "x 20", "x 21", "x 22", 
"x 23", "x 24", "x 25", "x 26", "x 27", "x 28", "x 29", "x 30", 
"x 31", "x 32", "x 33", "x 34")))

内部betareg:导致问题的NA

linkfun <- function(mu) {.Call(stats:::C_logit_link, mu)}
auxreg_test <- lm.wfit(x, linkfun(y), w, offset)
# problem:
(beta <- auxreg_test$coefficients)
is.na(beta['x 8'])

> beta['x 8']
x 8 
 NA 

我原本以为这可能与使用 betareg (3.1-0) 的 CRAN 版本有关。但是我通过devtools::install_github("rforge/betareg/pkg")更新到rforge版本(3.2-0),仍然有同样的问题。

如果我从我的公式中删除有问题的预测变量,betareg 运行正常;但是,预测器是必要的。

NA 来自 glm / lm / lm.fit / .lm.fit / lm.wfit 的系数暗示模型矩阵是秩亏的.它们只是 0,标准错误为 0(即固定为 0)。

我很感激你做了很多调试工作并找到了错误的根源,但是直接给我们一个模型矩阵 x 对我们调查来说信息量较少。如果能把模型公式和数据框给我们看看就好了

无论如何,我已经(有些痛苦地)从你的模型矩阵中发现了共线性问题。

rowSums(, x[, 2:9])
#2801 2316  382 8062 2687 2731 8019 5652 8429 3479 7753 9001 2188 8121 8478 5817 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
#1528 2460 3946 3531 3421 2802 1975 3639 2894 5897 9331 9490 7135 5858 7724 9414 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
#9095 6601 5064 7111 3593 7322 9522 7116 6922 5172 2458 5199 1387 3878 6119 8722 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
#6378 4661 6109 3682 5751 9390 7915 5268 1029 5953  242 2912 8798 9607 9768 2222 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
#8260  851 4205 1823 5063 4189 7541  608 6849 7220 2889 6770 7064  646 4919 1404 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
# 120 9716 7722 7700 6638 8176 5745    6 9481 2233  341  228 1543  553 9709 9493 
#   1    1    1    1    1    1    1    1    1    1    1    1    1    1    1    1 
# 881 7647 6039 2925 
#   1    1    1    1 

x1x8,如果全部包括在内,则与截距 存在共线性问题(奇怪;这些列不是虚拟列,因此它们不是来自因子变量) 。如果您不想删除其中任何一个,请删除拦截。