多元线性回归
黄冈职业技术学院数学建模协会胡敏
作业:
在农作物害虫发生趋势的预报研究中,所涉及的5个自变量及因变量的10组观测数据如下,试建立y对x1-x5的回归模型,指出那些变量对y有显著的线性贡献,贡献大小顺序。
x1 x2 x3 x4 x5 y
9.200 2.732 1.471 0.332 1.138 1.155
9.100 3.732 1.820 0.112 0.828 1.146
8.600 4.882 1.872 0.383 2.131 1.841
10.233 3.968 1.587 0.181 1.349 1.356
5.600 3.732 1.841 0.297 1.815 0.863
5.367 4.236 1.873 0.063 1.352 0.903
6.133 3.146 1.987 0.280 1.647 0.114
8.200 4.646 1.615 0.379 4.565 0.898
8.800 4.378 1.543 0.744 2.073 1.930
7.600 3.864 1.599 0.342 2.423 1.104
编写程序如下:
data ex;
input x1-x5 y@@;
cards;
9.200 2.732 1.471 0.332 1.138 1.155
9.100 3.732 1.820 0.112 0.828 1.146
8.600 4.882 1.872 0.383 2.131 1.841
10.233 3.968 1.587 0.181 1.349 1.356
5.600 3.732 1.841 0.297 1.815 0.863
5.367 4.236 1.873 0.063 1.352 0.903
6.133 3.146 1.987 0.280 1.647 0.114
8.200 4.646 1.615 0.379 4.565 0.898
8.800 4.378 1.543 0.744 2.073 1.930
7.600 3.864 1.599 0.342 2.423 1.104
;
proc reg;
model y=x1 x2 x3 x4 x5/cli;
run;
运行结果如下:
(1)回归方程显著性检验.
Analysis of Variance
Sum of Mean
Source DF Squares Square F Value Pr > F
Model 5 2.25207 0.45041 11.63 0.0170
Error 4 0.15497 0.03874
Corrected Total 9 2.40704
Root MSE 0.19683 R-Square 0.9356
Dependent Mean 1.13100 Adj R-Sq 0.8551
Coeff Var 17.40333
由Analysis of Variance表可知,其F Value=11.63,Pr > F的值0.0170小于0.05,故拒绝原假设,接受备择假设,认为y与x1 x2 x3 x4 x5之间具有显著性相关系;由R-Square的值为0.9356可知该方程的拟合度高,样本观察值有93.6%的信息可以用回归方程进行解释,故拟合效果较好,认为y与x1 x2 x3 x4 x5之间具有显著性的相关关系。
(2)参数显著性检验.
Parameter Estimates
Parameter Standard
Variable DF Estimate Error t Value Pr > |t|
Intercept 1 0.38113 1.31757 0.29 0.7868
x1 1 0.06054 0.05697 1.06 0.3479
x2 1 0.66119 0.13328 4.96 0.0077
x3 1 -1.14856 0.59877 -1.92 0.1275
x4 1 0.96868 0.42115 2.30 0.0829
x5 1 -0.33745 0.08628 -3.91 0.0174
由Parameter Estimates表可知,对自变量x1,t检验值为t=1.06, Pr > |t|的值等于0.3479,大于0.05,因此,接受原假设H0:β2=0,认为x1的系数为0,说明x1的系数没有通过检验。
为此,需要在程序model y=x1 x2 x3 x4 x5中去掉x1。
再次运行得到如下结果:
Parameter Estimates
Parameter Standard
Variable DF Estimate Error t Value Pr > |t|
Intercept 1 1.48612 0.81939 1.81 0.1295
x2 1 0.71294 0.12565 5.67 0.0024
x3 1 -1.58815 0.43840 -3.62 0.0152
x4 1 0.94190 0.42579 2.21 0.0779
x5 1 -0.37185 0.08100 -4.59 0.0059 由Parameter Estimates表可知,对x4检验t=2.21,Pr > |t|的值0.0779,大于0.05,因此,接受原假设H0:β2=0,认为x1的系数为0,说明x4的系数没有通过检验。
为此,需要在程序model y= x2 x3 x4 x5中去掉x4。
再次运行得到如下结果:
Parameter Estimates
Parameter Standard
Variable DF Estimate Error t Value Pr > |t|
Intercept 1 2.24871 0.95453 2.36 0.0566
x2 1 0.75463 0.15952 4.73 0.0032
x3 1 -1.99964 0.50976 -3.92 0.0078
x5 1 -0.33313 0.10156 -3.28 0.0168
以上结果表明所有变量的系数均通过检验,于是该线性模型即可得到。
(3)拟合区间.
Dependent Variable: y
Output Statistics
Dep Var Predicted Std Error
Obs y Value Mean Predict 95% CL Predict Residual
1 1.1550 0.9898 0.207
2 0.1839 1.7957 0.1652
2 1.1460 1.1498 0.1264 0.451
3 1.848
4 -0.003817
3 1.8410 1.4796 0.1668 0.7320 2.2272 0.3614
4 1.3560 1.6203 0.1332 0.9141 2.3264 -0.2643
5 0.8630 0.7790 0.1073 0.0998 1.4582 0.0840
6 0.9030 1.2496 0.1309 0.5460 1.9532 -0.3466
7 0.1140 0.1008 0.2074 -0.7054 0.9071 0.0132
8 0.8980 1.0046 0.2310 0.1608 1.8484 -0.1066
9 1.9300 1.7765 0.1454 1.0561 2.4969 0.1535
10 1.1040 1.1600 0.1070 0.4811 1.8389 -0.0560
以上为样本的拟合结果,其中Dep Var y 为因变量的原始值,Predicted Value为y的拟合值,95% CL Predict为拟合值95%的拟合区间,Residual为残差。
综合以上分析可以得到回归方程:y=0.75463x2 -1.99964x3 -0.33313x5+2.24871
故对y有显著的线性贡献大小顺序为x3 > x2 > x5。