Reg lab 2 #例2.2/4.5城镇人均收支分析 y<-c(1278.89,1453.8,1671.7,2110.8,2851.3,3537.57,3919.5,4185.6,4331.6,4615.9,4998,530 x<-c(1510.16.1700.6,2026.6,2577.4,3496.2,4282.95,4838.9,5160.3,5425.1,5854,6279.98,68 1.用最小二次乘法做一元线性回归 2.计算DW值和p值,并判断误差项是否存在自相关 3.用迭代法消除自相关 4.用差分法消除自相关 5.利用前两位所得方程做预测 #例5.2/3.1城镇居民消费因素分析 x1<-c(7535,7344,4211,3856,5463,5809,4635,4687,9656,6658,7552,5815,7317,5072,5201,4607,5838,5442 x2<-c(2639,1881,1542,1529,2730,2042,2045,1807,2111,1916,2110,1541,1634,1477,2197,1886,1783,1625, x3<-c(1971,1854,1502,1439,1584,1433,1594,1337,1790,1437,1552,1397,1754,1174,1572,1191,1371,1302, x4<-c(1658,1556,1047,906,1354,1310,1448,1181,1017,1058,1228,1143,773,671,1005,1085,1030,918,104 x5<-c(3696,2254,1204,1506,1972,1844,1643,1217,3724,3078,2997,1933,2105,1487,1656,1525,1652,1738, x6<-c(84742,61514,38658,44236,46557,41858,38407,36406,78673,50639,50197,44601,44525,38512,41904 x7<-c(87475,93173,36584,33628,63886,56649,43415,35711,85373,68347,63374,28792,52763,28800,51768, x8<-c(106.5,107.5,104.1,108.8,109.6,107.7,111,104.8,106,112.6,104.5,105.3,104.6,106.7,106.9,106. x9<-c(1.3,3.6,3.7,3.3,3.7,3.6,3.7,4.2,3.1,3.1,3,3.7,3.6,3,3.3,3.1,3.8,4.2,2.5,3.4,2,3.3,4,3.3,4, y<-c(24046,20024,12531,12212,17717,16594,14614,12984,26253,18825,21545,15012,18593,12776,15778,1 1.算相关系粉矩阵 2.对全模型做线性回归拟合 3.分别使用前进法,后退法,逐步回归法筛选变量,α=0.05
Reg lab 2 # 例 2.2/4.5 城镇人均收支分析 y <- c(1278.89, 1453.8, 1671.7, 2110.8, 2851.3, 3537.57, 3919.5, 4185.6, 4331.6, 4615.9, 4998, 5309.01, 6029.92, 6510.94, 7182.1, 7942.88, 8696.55, 9997.47, 11242.85, 12264.55, 13471.45, 15160.89, 16674.32) x <- c(1510.16, 1700.6, 2026.6, 2577.4, 3496.2, 4282.95, 4838.9, 5160.3, 5425.1, 5854, 6279.98, 6859.6, 7702.8, 8472.2, 9421.6, 10493, 11759.5, 13785.8, 15780.76, 17174.65, 19109.4, 21809.8, 24564.7) 1. 用最小二次乘法做一元线性回归 2. 计算 DW 值和 𝜌 值,并判断误差项是否存在自相关 3. 用迭代法消除自相关 4. 用差分法消除自相关 5. 利用前两位所得方程做预测 # 例 5.2/3.1 城镇居民消费因素分析 x1 <- c(7535,7344,4211,3856,5463,5809,4635,4687,9656,6658,7552,5815,7317,5072,5201,4607,5838,5442,8258,5553,6556,6870,6074,4993,5468,5518,5551,4602,4667,4769,5239) x2 <- c(2639,1881,1542,1529,2730,2042,2045,1807,2111,1916,2110,1541,1634,1477,2197,1886,1783,1625,1521,1146,865,2229,1651,1399,1760,1362,1789,1631,1512,1876,2031) x3 <- c(1971,1854,1502,1439,1584,1433,1594,1337,1790,1437,1552,1397,1754,1174,1572,1191,1371,1302,2100,1377,1521,1177,1284,1014,974,845,1322,1288,1232,1193,1167) x4 <- c(1658,1556,1047,906,1354,1310,1448,1181,1017,1058,1228,1143,773,671,1005,1085,1030,918,1048,884,993,1102,773,655,939,467,1212,1050,906,1063,1028) x5 <- c(3696,2254,1204,1506,1972,1844,1643,1217,3724,3078,2997,1933,2105,1487,1656,1525,1652,1738,2954,1626,1320,1471,1587,1396,1434,550,2079,1388,1097,1516,1281) x6 <- c(84742,61514,38658,44236,46557,41858,38407,36406,78673,50639,50197,44601,44525,38512,41904,37338,39846,38971,50278,36386,39485,44498,42339,41156,37629,51705,43073,37679,46483,47436,44576) x7 <- c(87475,93173,36584,33628,63886,56649,43415,35711,85373,68347,63374,28792,52763,28800,51768,31499,38572,33480,54095,27952,32377,38914,29608,19710,22195,22936,38564,21978,33181,36394,33796) x8 <- c(106.5,107.5,104.1,108.8,109.6,107.7,111,104.8,106,112.6,104.5,105.3,104.6,106.7,106.9,106.8,105.6,105.7,107.9,107.5,107,107.8,105.9,105.5,108.9,109.5,109.4,108.6,110.6,105.5,114.8) x9 <- c(1.3,3.6,3.7,3.3,3.7,3.6,3.7,4.2,3.1,3.1,3,3.7,3.6,3,3.3,3.1,3.8,4.2,2.5,3.4,2,3.3,4,3.3,4,2.6,3.2,2.7,3.4,4.2,3.4) y <- c(24046,20024,12531,12212,17717,16594,14614,12984,26253,18825,21545,15012,18593,12776,15778,13733,14496,14609,22396,14244,14457,16573,15050,12586,13884,11184,15333,12847,12346,14067,13892) 1. 计算相关系数矩阵 2. 对全模型做线性回归拟合 3. 分别使用前进法,后退法,逐步回归法筛选变量,𝛼 = 0.05 1