R 最佳拟合多元回归模型与多重共线性检验

R 最佳拟合多元回归模型与多重共线性检验,r,linear-regression,non-linear-regression,multicollinearity,R,Linear Regression,Non Linear Regression,Multicollinearity,我已经开始在R最近的工作,我需要帮助的数据粘贴在下面。这里我有2019年在印度调查的41个地区的数据,我必须使用2019年的2011年数据估计整个60个地区的数据。A 步骤AIC中的错误(运行.5,direction=“backward”): 此模型的AIC为-无穷大,因此“stepAIC”无法继续 独立变量:FW_19:LPG_19 从属变量:FW_11:永久变量 #这是我的数据集: structure(list(Region = c("East", "East&

我已经开始在R最近的工作,我需要帮助的数据粘贴在下面。这里我有2019年在印度调查的41个地区的数据,我必须使用2019年的2011年数据估计整个60个地区的数据。A

步骤AIC中的错误(运行.5,direction=“backward”): 此模型的AIC为-无穷大,因此“stepAIC”无法继续

独立变量:FW_19:LPG_19 从属变量:FW_11:永久变量 #这是我的数据集:

structure(list(Region = c("East", "East", "East", "East", "East", 
"East", "East", "North", "North", "North", "North", "North", 
"North", "North", "North", "North", "North", "North", "North", 
"North", "North", "North", "North", "North", "North", "North", 
"North", "South", "South", "South", "South", "South", "South", 
"West", "West", "West", "West", "West", "West", "West", "West"
), District_code = c(209, 294, 302, 305, 338, 374, 393, 101, 
106, 11, 111, 113, 134, 14, 155, 180, 188, 189, 31, 40, 53, 67, 
70, 76, 8, 83, 99, 540, 554, 573, 575, 594, 624, 442, 445, 464, 
479, 481, 486, 499, 509), FW_19 = c(20.4849084611578, 20.6185567010309, 
15.6405472636816, 63.4861503334736, 65.338860850757, 88.5388398914518, 
97.7499679938548, 33.5590303755799, 43.8186209925341, 48.6905790838375, 
57.0384223053383, 69.4404591104735, 77.8827233372688, 28.1290322580645, 
43.3077027762657, 5.61224489795918, 6.55270655270655, 1.96078431372549, 
31.350626118068, 1.78571428571429, 14.0374331550802, 43.4416666666667, 
8.10810810810811, 27.4038461538462, 41.1453045685279, 56.3441597847022, 
70.0822853594162, 2.06896551724138, 12.4753646038628, 50.1428571428571, 
70.6241906241906, 54.8694492090719, 8.33333333333333, 49.8351839000694, 
47.3335319529271, 33.3469387755102, 47.4154558312974, 63.3161976911977, 
44.8838375396958, 20.249433106576, 20.7998350855494), CR_19 = c(2.4113475177305, 
0, 0, 1.4514896867838, 3.28947368421052, 0.746268656716418, 0.684931506849315, 
23.2046070460705, 44.8726394378568, 0, 6.66666666666667, 20.4208512673362, 20.4545454545454, 0, 68.5424289332958, 49.5657837603127, 57.6793576793577, 63.2325555920693, 9.6153846153846, 46.0820895522388, 39, 11.820652173913,36.7181467181467, 27.4038461538462, 0, 39.8949531856588, 4.42477876106195, 0, 0, 0, 0, 0, 0, 18.4961315280464, 27.3855488141202, 0.714285714285714,
0.649350649350649, 1.42857142857143, 1.0752688172043, 0, 0),CD_19 = c(61.2804293655357, 0, 0, 2.31729055258467, 5.14354066985646,0, 0.684931506849315, 0, 16.5788317962231, 0, 0.980392156862745, 
    0, 0, 0, 8.80681818181817, 47.6787661629537, 39.5397764628534, 
    48.1838637094182, 1.92307692307692, 0, 0, 1.04166666666667, 
    0, 0, 0, 0, 0.884955752212389, 0, 0, 1.28571428571429, 0, 
    13.9438564196963, 0, 2.75974025974026, 0, 0, 0.649350649350649, 
    10.8571428571429, 0.645161290322581, 2.24489795918368, 1.01010101010101
    ), Coal_19 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.561797752808989,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.35135135135135, 0, 0, 0, 0.884955752212389, 0, 0, 0, 0, 0, 0, 0, 0, 0.714285714285714, 
    0, 0.649350649350649, 0, 0, 0), Kero_19 = c(0.709219858156028,0, 0, 1.06951871657754, 0, 1.49253731343284, 0.684931506849315,0, 0, 0.561797752808989, 0, 0, 0, 1.56682027649769, 0.568181818181818,0, 0.854700854700855, 0, 0, 0, 0, 0, 1.35135135135135, 6.25, 
    1.5625, 0, 0, 0, 0, 0.714285714285714, 0, 0, 0, 1.13636363636364,0, 0.714285714285714, 0, 0.649350649350649, 0.645161290322581,0, 0), LPG_19 = c(14.687714481812, 79.3814432989691, 84.2948717948718,31.4778804083617, 29.6783625730994, 19.9904731660845, 2.64187866927593, 
    45.1871809415768, 31.840703579834, 23.4561797752809, 35.9536541889483, 
    46.2049276981319, 11.946386946387, 57.4773468648061, 0, 0,0, 0, 64.4131641554322, 62.2054491899853, 51.3636363636364,44.8079427083333, 61.4653716216216, 39.8026315789474, 54.9358365019012, 
    39.9021019291679, 33.6283185840708, 97.3391257127342, 87.8985230802768,46.9506889050036, 28.8888888888889, 55.280202759786, 88.9467592592593,26.9366197183098, 25.7859900717043, 2.57142857142857, 58.5299914093688,25.7742257742258, 57.9615915652065, 83.7196607037877, 77.5739854687223
    ), FW_11 = c(16.7441763860645, 98.4741594775458, 79.050060992219,81.3711974810915, 42.5728016712418, 92.2793005579833, 93.1781744956047,75.3513517971727, 31.6222973056597, 75.1488013979141, 78.8254582021132, 85.4023180369986, 63.9432301681999, 81.8718311789156, 52.2830692741669, 
    74.9382608284506, 67.1363820112975, 53.2423561083455, 59.5102687248681,4.11024149116935, 9.68997107263415, 67.5430802023678, 28.7793823594757,40.0424880467701, 73.146563598267, 33.9548905761501, 35.1641996863914,83.9343261980762, 79.1094436084026, 84.12451383848, 81.4058494787279, 
    62.7765988466274, 58.6459511905289, 79.4630687209924, 88.2900427670525,70.6984587260062, 66.7463156347369, 62.9999967075696, 71.5860771491533,63.5444127094001, 80.0072594663725), CR_11 = c(75.2997955102896,0.477707006369427, 12.8746876369364, 7.0140439143038, 29.743525095641, 
    1.20606766593084, 1.49246795492391, 3.16464048298501, 59.6220250250622, 
    1.14399606836673, 3.01415016870136, 3.59535231404539, 13.7088910464631, 
    2.99821860868771, 8.3006319663597, 17.1900402623051, 13.7213761622146, 
    39.0075348543412, 1.3297407365509, 2.16518201946347, 6.29437193256163, 
    2.72374739977914, 1.88846922906021, 5.73366761700853, 5.54966566770459, 
    31.9458091409856, 54.2617037918469, 1.57070711716601, 1.12748836985577, 
    1.94860033498188, 0.487758484823782, 0.69736927363442, 1.13206116037849, 
    3.2319398195276, 1.59711986855776, 23.1973818304073, 6.87786613785132, 
    19.8905596143906, 12.2964968449401, 10.4476042916706, 3.19331448518757
    ), CD_11 = c(5.7496917548918, 0.147141820527292, 1.04811871572889, 
    1.66261286775731, 9.20006277447754, 0.883956210862332, 3.34972698756922, 
    16.0900153407123, 5.26739192316737, 1.19314148419156, 0.25125121375658, 
    3.86944289215153, 11.1365080430219, 3.8870871968209, 35.5329744388575, 
    3.95785369543948, 7.87926920448895, 3.55160848836685, 0.0976994354001049, 
    42.2828381648731, 48.8909628680346, 2.25686329900614, 29.1410797600533, 
    20.958920825799, 5.83933684500505, 9.5503945213637, 0.871135033344083, 
    0.239477258859279, 0.106372013440805, 0.0505579736138218, 
    0.0502703730876878, 0.041307587636882, 0.146011238440777, 
    14.6955606549457, 6.0221808780535, 2.77891596011809, 9.24658225221148, 
    2.44792198256987, 1.46997380930211, 0.594519936472407, 0.681709264043239
    ), Coal_11 = c(0.0645756980123147, 0.0141094896396033, 0.0527020145197011, 
    0.0853796688101823, 6.08642296105152, 1.78142758767159, 0.0420813486684997, 
    0.0478366296620095, 0.0625007735244248, 0.0218424070332551, 
    0.0602196143063363, 0.0374969458132846, 0.14553140983029, 
    0.0328872242269218, 0.0476194319566744, 0.0432810687150614, 
    0.207490403568835, 0.113549202147659, 0.0452502648168907, 
    0.0926831780031924, 0.0882215009727581, 0.12121523408408, 
    0.0604310153299267, 0.0748810223755588, 0.0434089372323463, 
    0.0736936132201876, 0.0430007080288994, 0.18949672980158, 
    0.100187594054711, 0.0355882942756511, 0.0715560265572494, 
    0.0323981079504957, 0.060679995196167, 0.0196690764160872, 
    0.0183632541619349, 0.00735440896817642, 0.0928117046512499, 
    0.0770428707358911, 0.0467946835509525, 0.101889978231125, 
    0.61336819389581), Kero_11 = c(0.0749606786868098, 0.0947351447230509, 
    0.0538863294527281, 0.128485989404591, 0.257529721399665, 
    0.389043705472355, 0.106623294479082, 0.145159427939891, 
    0.064976051683808, 1.41156555452411, 0.123320549871349, 0.194258370890758, 
    0.198375668154834, 0.217421093500206, 0.123810523087353, 
    0.165122732744856, 0.337708518912035, 0.171639770796048, 
    5.10916626387075, 3.22846403377787, 1.02522670604132, 0.521328231336193, 
    1.263719173517, 0.500316164316697, 1.03179704652269, 0.198005061783534, 
    0.183123704881692, 0.612184823703649, 0.947865344575233, 
    0.962861072902338, 0.228254666992745, 0.202083198341217, 
    5.10849709557731, 0.17391604410014, 0.190881194578008, 0.223784158603083, 
    2.49957485321627, 2.62077457716963, 1.68174362720872, 0.920729596936185, 
    0.670366347836197), LPG_11 = c(1.13781624626377, 0.630895751027977, 
    5.58108412188969, 8.92217539066405, 9.1653309938692, 2.27666188272697, 
    1.07242897158864, 4.99604110651073, 3.16031138999245, 18.4322612351881, 
    17.5152637993678, 6.64953902948228, 10.2899514126403, 9.95386653268168, 
    3.44990677890863, 3.40411061040855, 9.99835438645445, 3.53262095621964, 
    33.019323919907, 45.163740281139, 29.5871698078164, 25.1424022188551, 
    37.8831370806487, 32.2964622876984, 12.73050563064, 23.9481911567664, 
    9.15618524408462, 12.7278636850061, 17.2007943543123, 12.0912642035424, 
    16.3768194704854, 35.0948454610251, 33.5383390115482, 2.13875325661243, 
    3.10870563220335, 2.79152351834925, 11.798039424798, 11.1277561757763, 
    12.1265079944897, 23.5205736890965, 13.2927635030328), Cook_in_11 = c(51.0978812751246, 
    51.9471095702653, 53.2586425382238, 65.1213640755673, 83.8297834023252,93.6047521897787, 93.2863467967832, 88.1018755257905, 86.4818871520687,91.5196854693387, 81.1662435926618, 91.7772826568159, 70.549601256519,95.618690905769, 96.6672854502458, 94.0666746682088, 84.1455867148903, 
    84.3396098720128, 86.6851095776299, 93.3075021883528, 92.6223609002308,66.8553378361026, 89.2717173961342, 89.8056421463674, 94.3501598617592,91.4210212892661, 81.0934042103624, 41.5210945429235, 68.6954310883891,97.0077588130457, 96.5933896723821, 95.3261679517916, 85.3369319941595, 97.6952673441571, 97.4470244279605, 98.3815047120749, 75.2930630456651, 
    66.1034415774692, 88.0988704813884, 88.3656200571231, 92.7476229501224), Cook_out_11 = c(48.7680580652592, 47.9702491332742, 46.1865059156531,34.4161280111951, 15.821741065571, 6.09019120741918, 6.50995882223857,11.8214209128549, 13.4036312330598, 8.37383279637416, 18.7199442176204,8.09159899072737, 29.2446835950033, 4.24427899328553, 3.18162374191882, 
    5.79929950135844, 15.5923672150853, 15.4782226165947, 12.7718872445674,6.23938005252047, 6.94767536344937, 32.9284265132643, 10.4296822928238,10.0140887256914, 5.55133524221352, 8.427869584636, 18.7368171320752,58.2046258052845, 30.9721220117229, 2.86852949732947, 3.27255599938407, 
    4.45433486684378, 13.6934522492684, 2.23709863869287, 2.47662309420833,1.53759678927517, 24.456172410712, 33.6878183368617, 11.5857429014136,11.2103235572864, 6.72748360239676), HH4_11 = c(17.2, 16.7,20.7, 20, 29.6, 21.6, 23, 12.5, 12.5, 13, 16.5, 14.5, 14.5,14.7, 13.1, 13.5, 10.9, 11.4, 24.5, 22.1, 22.2, 18.8, 22.2,21.6, 12.2, 23.8, 21.4, 31, 28.9, 30.6, 24.9, 30.7, 31.3,9, 18.5, 19.9, 19.7, 13.1, 19.6, 23.2, 29.9), HH9_11 = c(4.8,9.3, 7, 7.2, 4.3, 2.7, 1.2, 16.7, 13, 8.7, 15.2, 11.6, 11.7, 
    18.3, 12.9, 12.9, 21.4, 18.7, 7, 8.3, 7.7, 7.8, 8.3, 7.7,6.6, 7.8, 6.8, 1.1, 1.4, 3.1, 7.5, 2.8, 0.7, 3.4, 3.7, 2,8.1, 10.2, 7.3, 4.6, 1.2), FM_ilit = c(66.5098719943746,45.7714023206532, 49.0947040950906, 45.7316814724134, 35.2535616396464,49.85013367252, 56.3150380578989, 63.9834042788286, 57.5248324721091, 
    63.4970692078292, 51.1975404585334, 66.2163801611223, 50.4743405744855, 
    60.7981434173699, 57.3644956629371, 70.547705932459, 52.6784217798011,56.5498241359855, 33.9585968998017, 34.5335532366375, 47.3820084519531,46.5907847214622, 38.3654473372021, 42.1191254610854, 58.7136897797222,39.6633489195912, 51.9684899484357, 55.8614344154602, 48.3554696702905,46.206866050895, 27.9972612615224, 16.7085747943582, 42.6860384201759, 
    62.0389725420726, 54.1179850226471, 76.7502797483661, 44.5614062487798, 
    48.7523684435873, 49.824642434965, 42.5025888950106, 40.1298762277273
    ), M_B_Mid = c(39.3162399381774, 52.9031514164439, 46.445298751929, 
    50.968237029221, 58.4329157343966, 49.729465083394, 51.286414094982, 
    47.5703464916232, 52.7702378438562, 34.4830422914408, 45.9385432886319, 
    47.3111761382751, 48.5102321170847, 35.9123334598503, 48.6608325590839, 
    37.6837773328409, 44.7938953384028, 46.3943406552445, 42.3166864208604, 
    43.2442626675755, 37.9705384741331, 46.2457536287173, 43.9390056767651, 
    38.6101160092807, 37.4663216149899, 38.4710282417059, 48.2584676414307, 
    34.8888698502452, 42.502706824454, 42.7029602938064, 56.8990034793272, 
    50.8178323704749, 46.717202970297, 47.5836935751773, 53.0300954139291, 
    32.505112649422, 53.0142905609128, 58.8564200485018, 49.2490790329359, 
    46.6720070589145, 50.7742671180241), FM_B_Mid = c(29.0364183020138, 
    48.8152220625065, 43.4413191621943, 46.4708468488235, 52.2033625931747, 
    39.9212686523219, 37.7991992761944, 32.8479664312597, 38.300436394179, 
    26.5605182874576, 37.7490817885895, 30.658316003039, 39.5011633910518, 
    28.887479761846, 36.5518830415614, 25.132228309685, 34.9323344884601, 
    34.0928898118915, 40.4597328804003, 40.236139155633, 34.4689281284667, 
    38.6210306602667, 40.9121481176045, 35.8774108022285, 29.0835325838124, 
    36.0940253349736, 38.9258098471132, 29.3945376847042, 36.4099505251848, 
    35.2181289904096, 51.1607940167983, 46.0557586240962, 39.8217461288123, 
    34.2404380384894, 40.825485898228, 21.0954967493347, 42.851118754037, 
    46.3960459806713, 42.2426784302367, 43.4337978440779, 43.0082680845675
    ), M_A_Mid = c(9.40604866349307, 8.13977789468374, 11.329876997771, 
    10.5446508151577, 17.5861678695489, 15.5735813557216, 12.5035333507142, 
    9.88016079198085, 13.3820282955483, 21.5196500018696, 26.119245533758, 
    13.4427704534058, 17.0437259978365, 18.8337566786371, 13.3637647044011, 
    8.68285586524156, 23.2374481026537, 18.4380629192367, 35.8502578723132, 
    29.8854805725971, 24.4763525526211, 22.6838883136229, 29.7057910238979, 
    35.6566125290023, 22.8668428927911, 38.7851719982614, 17.2769821791475, 
    27.0991294580174, 25.2527726294595, 26.2366504579743, 24.5076493488266, 
    34.9117248921264, 26.7048267326733, 11.7299782389764, 13.798960038656, 
    5.56829558386884, 19.4338653430766, 10.7802074737032, 17.1607404102072, 
    25.3199903499734, 23.817183716978), FM_A_Mid = c(4.45370970361156, 
    5.4133756168403, 7.46397674271511, 7.79747167876308, 12.5430757671789, 
    10.2285976751581, 5.88576266590671, 3.16862928991173, 4.17473113371191, 
    9.94241250471326, 11.0533777528771, 3.12530383583873, 10.0244960344628, 
    10.3143768207842, 6.08362129550147, 4.32006575785598, 12.3892437317388, 
    9.35728605212297, 25.581670219798, 25.2303076077295, 18.1490634195802, 
    14.7881846182711, 20.7224045451934, 22.0034637366861, 12.2027776364654, 
    24.2426257454352, 9.10570020445114, 14.7440278998356, 15.2345798045248, 
    18.5750049586954, 20.8419447216793, 37.2356665815456, 17.4922154510118, 
    3.72058941943796, 5.05652907912497, 2.1542235022992, 12.5874749971832, 
    4.85158557574135, 7.9326791347983, 14.0636132609116, 16.8618556877052
    ), P_A_TDip = c(1.86624600044196, 0.608274728285688, 1.32912548944342, 
    1.66027363323954, 3.99207112744887, 2.14831702746174, 1.63686539690938, 
    1.37718388823404, 1.87265527085727, 3.61132076978679, 4.28794373373749, 
    1.86006403993146, 3.42532696550121, 3.21536054686764, 2.20121491202997, 
    1.64850686100109, 3.78301948032133, 2.98194843596392, 5.97838020967307, 
    3.83523720643097, 2.909663238542, 4.97127502725624, 4.67943324792535, 
    4.8525190214692, 3.81774816210985, 5.49054213177525, 2.92006338684388, 
    4.29224483512106, 4.8608784243468, 4.0176117782273, 5.00062639280956, 
    9.48785804756858, 5.77997212461202, 1.78231970990037, 1.87163058511389, 
    0.974958872104301, 3.52387745212804, 1.51640435250688, 2.24539313428784, 
    3.6749369459609, 3.18266337935615), M_agri = c(43, 36.5, 
    32.5, 34.6, 36.4, 35.8, 40.9, 39.7, 37.8, 14, 28.4, 32.7, 
    30.6, 24.4, 43.3, 41.7, 27.3, 32.5, 28.1, 26.5, 34.3, 34.1, 
    27.2, 29.6, 21.1, 27.8, 41.2, 41.7, 42.4, 50.1, 7.4, 9.6,39.9, 48.9, 43.6, 45.8, 43.7, 36.9, 49.1, 46.6, 47.9), FM_agri = c(18.3,21.7, 20.3, 4, 11.2, 7.3, 18, 39, 29, 5.5, 24.8, 38.6, 6.5, 
    7, 17.9, 11.7, 23.4, 29.7, 21.6, 13.6, 3.3, 42.6, 22.5, 3.2,21.3, 24.3, 30.7, 27.3, 35.5, 25.9, 29, 12.8, 21.3, 47, 41.6,26.9, 12.1, 41.3, 26.1, 43.4, 41.8), P_worker = c(95.1693300171139, 
    89.4442108936886, 86.6305543987004, 86.6741564778704, 63.776772401492,71.6310879072681, 90.6589083279096, 74.2292700931244, 85.8829690450525,83.752601843592, 81.9966935054406, 72.4645424942993, 76.0577775000092,75.9456380041264, 87.7286863904967, 92.7465803360644, 81.2419680252495, 95.9287288054411, 84.7444407622759, 68.9547124306859, 69.7117227362077,68.6657378884046, 52.6271097627499, 71.9042622123594, 78.2488494411571,77.7355497436714, 79.6662985168823, 79.2428715068405, 77.0948665973227,86.0291619998898, 56.984968743767, 34.6070690965907, 51.5563465744487, 
    87.4733604880882, 85.9961063801108, 93.6412998111123, 73.2507259441724, 
    63.7938976145284, 58.6038277551517, 76.6104967291292, 75.3609999130576
    ), TV_11 = c(5.38772797392803, 21.1743126662904, 17.3792294847046, 
    16.2781544663979, 35.5868255924341, 15.4603844742922, 14.386657888962, 
    15.6788677564621, 17.2223666134482, 43.2152023152952, 42.7478584579745, 
    19.0157898429241, 38.411694518247, 38.9284246106061, 14.4879296846625, 
    8.785147683008, 27.5894265752278, 16.937254666045, 77.1517015127986, 
    84.9853251634828, 75.5310702196715, 58.4863504455687, 77.1304154632304, 
    66.4311150061569, 45.3356262156589, 65.8672026202174, 39.0587293290777, 
    43.4442717101007, 51.4167130498121, 50.9324980440561, 53.3576986132623, 
    79.104030324629, 85.9620623613367, 15.5537535154161, 33.0127817913838, 
    5.28782004811885, 52.6844776747497, 41.3239521017229, 27.9820270215423, 
    37.2860714782457, 27.5303919261122), TwoW_11 = c(5.13792198424882, 
    6.03281464161896, 6.33312410436183, 6.70542764801919, 12.0678787629312, 
    9.96067730288774, 7.33919374201293, 5.29914388928294, 12.6313444473323, 
    5.32135641347677, 14.5385708070293, 18.1078799226837, 20.5658529629482, 
    3.09688028136847, 9.84317871814946, 7.45961949030177, 16.7414347603665, 
    12.0268156592622, 19.7486553472444, 56.3899902167757, 45.7846373864148, 
    27.4490870335653, 37.8840257720507, 27.4635856361559, 4.18311893214014, 
    26.9398541015334, 17.9464937741647, 9.26142269729277, 13.2132181657012, 
    19.9972320215563, 17.3677345724301, 24.7501295924318, 14.2597988710993, 
    11.2828033609966, 21.1607509604465, 6.8937077778128, 34.7355010534993, 
    32.2068831549385, 18.3060324554555, 12.4085820473093, 11.2964102505934
    ), FourW_11 = c(0.814748938371748, 1.12271224703701, 1.43953480109431, 
    1.71113350881285, 1.41769982994291, 1.07284674445396, 0.727258645393641, 
    3.00092374181416, 1.23083206475328, 4.40670561895921, 4.88499206195993, 
    3.81573758911573, 2.33101895053819, 3.85785410861919, 1.29686276725397, 
    2.00565927251434, 2.89610096912328, 2.15912679911567, 10.4630953237965, 
    14.4572885021369, 10.230908170704, 4.73972110223683, 7.6009775605421, 
    5.60831123880945, 5.20239416984581, 6.02724430549352, 4.93062428872751, 
    0.871286339370859, 0.773327286345489, 1.30914082514002, 7.36845919042055, 
    7.79174496209421, 1.27175156598633, 0.770544695388119, 1.75610699011767, 
    0.599909645832677, 2.02023986925656, 1.80853200406944, 1.75336814284793, 
    1.23901448131532, 0.893821797114929), Elec_L_11 = c(4.7, 
    35.5, 35.6, 27.6, 66.8, 25.6, 22.7, 40.1, 39.1, 87.8, 71.2, 
    49.8, 32.7, 75.6, 6.5, 9.8, 31.8, 20.7, 97.2, 97.9, 96.7, 
    80.5, 94.7, 92.3, 94, 90.4, 69.4, 91.9, 90.3, 90.8, 84.7, 
    95.7, 91.3, 65.4, 55.7, 52.5, 93, 89.4, 83.2, 75, 72), Bank_11 = c(19.2, 
    19.4, 30, 32.3, 49.9, 48.2, 28.1, 77.1, 45.6, 57.8, 70.6, 
    57.9, 77.8, 57.9, 68.7, 66.1, 79, 85.6, 84, 71.4, 62.2, 72.4, 
    69.8, 69.3, 64, 74.2, 81.9, 44.3, 65, 54.9, 84.3, 71.7, 42.4, 
    29.5, 50.1, 46.6, 66.9, 45.5, 42.2, 46.4, 65.3), Permanent_11 = c(13.3424343527608, 
    9.6468596307345, 22.3006501888982, 21.2330906607137, 49.51452688883, 
    29.4530862846809, 41.7563154293976, 49.8936047374759, 79.7998737608139, 
    68.4895975536504, 92.3287702809, 72.2861283072911, 71.9682179532077, 
    71.4776412551957, 49.6669061090081, 43.3892713868491, 73.3178073272732, 
    61.0180325156788, 80.9228997192427, 89.7456361670357, 89.9627148077468, 
    75.2310023369886, 71.14419017996, 73.3284891783056, 74.3419789466654, 
    86.049575703439, 40.7457657276943, 59.2536036574709, 77.9497962577391, 
    62.5619617623549, 57.2421039283353, 77.2046912460312, 72.2382701144703, 
    36.7352783864456, 48.8873317708459, 38.9799434761139, 88.2230017380577, 
    66.4619872451247, 51.8303644971601, 39.274219894746, 41.5666835865167
    )), row.names = c(NA, -41L), class = "data.frame")
代码:
lmm在这方面我需要立即帮助,如果有人能帮助我,我请求。任何函数都可以,我只需要得到预测的最佳拟合模型。
lmm <- list()
steplmm <- list()
compiled.data <- data.frame()
region <- c("North","South","East","West")
k <- 0
for(j in region){
  for(i in 1:6){
    data <- df5 %>% filter(Region== j) %>% dplyr::select(3:ncol(df5))
    model.name <- as.formula(paste(colnames(data)[i],sep = "~", paste(names(data)[c(7:31)],collapse = "+")))
    run.5 <- lm(model.name, data = na.omit(data))
    lmm[[paste(j, colnames(df5)[i])]] <- run.5
    steplmm[[paste(j, colnames(df5)[i+2])]] <- stepAIC(run.5, direction = "backward")
    compiled.data[i+k,"DepV"] <- paste(j, colnames(df)[i+2])
    compiled.data[i+k,"Model name"] <- as.character(steplmm[[i]]$call)[2]
  }
  k <- k + 6
}
# Creating model data frame to export in excel
model.excel.2 <- data.frame()
for(i in 1:24){  
  model.excel.2 <- steplmm[[i]] %>% summary() %>% coefficients() %>% as.data.frame() %>% rownames_to_column() %>% mutate(modelcode= compiled.data[i,1], modelname= compiled.data[i,2], AIC= AIC(steplmm[[i]]), iteration = i,R2= summary(lmm[[i]])$r.squared, adj.R2= Summary(lmm[[i]])$adj.r.squared) %>% rename(coefficient= rowname) %>% dplyr::select(iteration, modelcode, modelname, coefficient, Estimate:AIC,R2,adj.R2) %>% bind_rows(model.excel.2) 
  model.excel.2 <- arrange(model.excel.2, iteration) 
}
write.xlsx(model.excel.2, file = "Date_Models.xlsx", sheetName = "Census_region", append = T)
# selecting the required model
my.model.2 <- list()
for (i in 1:24) {
  run1.1 <- lm(compiled.data[[i,2]], data = na.omit(data))
  my.model.2[[paste(compiled.data[[i,1]])]] <- run1.1  
}