前言
本章首先針對每個解釋變數膀胱癌(x )、肺癌(1 x )、腎癌(2 x )與白血症(3 x )與反應變數菸4 頭數(y )配適簡單線性回歸模型。接著考慮放入兩個解釋變數配進入模型中配適複回歸模型,
而利用偏回歸圖觀察若已有一個解釋變數在模型中,加入另一解釋變數進入模型是否對模型
有幫助,並利用 Contour 圖形觀察解釋變數之間是否有交互作用存在。依序放入三個解釋變
數與四個解釋變數分別配適模型,最後依整體現象選擇出最合適的模型。
第一節
此節為針對每個解釋變數膀胱癌(x )、肺癌(1 x )、腎癌(2 x )與白血症(3 x )與反應變數菸頭4 數(y )配適簡單線性回歸模型。
由 Table 2.1.1-2.1.8 看出x1、x2、x 的 p-value<0.01,參數檢定皆顯著,表示具解釋能力。3 而x4的p-value = 0.6587>0.01,參數不顯著。而相對於其他變數而言,x1的R2 =0.4951為最
大, MSE =4.0071為最小,因此就簡單回歸而言解釋變數x1對y 的解釋能力最高。另外,由
Figure 2.1.4 發現其散佈圖點的散佈情況完全沒有呈現直線的樣子,由x4的R2 =0.0047解釋y 總變異能力僅有0.47%,且 MSE = 5.6260為最大,加上x4的參數檢定並不顯著,因此x4對y 而言可能不具解釋能力。
4.064 1
8.1657
ˆ x
y= + (2.1.1)
Table 2.1.1. Parameter estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 8.1657 2.6789 3.05 0.0040
x1 1 4.0640 0.6333 6.42 <.0001 Table 2.1.2. Analysis of Variance
Source DF Sum of Squares
Mean
Square F Value P-value Model 1 661.2562 661.2562 41.18 <.0001
Error 42 674.3890 16.0569
Total 43 1335.6453 1335.6453
Root MSE 4.0071 R-Square 0.4951 Dependent Mean 24.9141 Adj R-Sq 0.4831
Coeff Var 16.0837
0.9193 2
6.8473
ˆ x
y = + (2.1.2)
Figure 2.1.2: Scatter plot Number of cigarettes smoked on x2(Lung Cancer)
Table 2.1.3. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 6.8473 2.9289 2.34 0.0242
Table 2.1.4. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 1 649.6181 649.6181 39.77 <.0001 Error 42 686.0271 16.3340
Total 43 1335.6453
Root MSE 4.0415 R-Square 0.4864 Dependent Mean 24.9141 Adj R-Sq 0.4741
Coeff Var 16.2219
5.233 3
10.2902
ˆ x
y= + (2.1.3)
Figure 2.1.3: Scatter plot Number of cigarettes smoked on x (Kidney Cancer) 3
Table 2.1.5. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 10.2902 4.1103 2.50 0.0163
x 1 5.2330 1.4466 3.62 0.0008
Table 2.1.6. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value
Model 1 317.2807 317.2807 13.09 0.0008
Error 42 1018.3646 24.2468
Total 43 1335.6453
Root MSE 4.9241 R-Square 0.2375 Dependent Mean 24.9141 Adj R-Sq 0.2194
Coeff Var 19.7643
0.598 4
28.9982
ˆ x
y= − (2.1.4)
Figure 2.1.4: Scatter plot Number of cigarettes smoked on x4(Leukemia)
Table 2.1.7. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 28.9982 9.2200 3.15 0.0030
x4 1 -0.5980 1.3442 -0.44 0.6587
Table 2.1.8. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value Model 1 6.2638 6.2638 0.2 0.6587
看出x1與x2的contour plot 並未呈曲線狀,交互作用並不顯著;而由 Table 2.2.1-2.2.4 看出對 x1與x2此兩變數而言,未加入交互作用項x1*x2前,x1與x2的p-value<0.01,兩參數估計值皆 為顯著,但加入交互作用項x1*x2後,x1與x2及x1*x2的 p-value>0.01,參數估計值皆變為不 顯著;未加入交互作用項x1*x2前的Radj2 =0.5719較加入後的Radj2 =0.5630來的大,解釋力較 高,而未加入交互作用項x1*x2前的 MSE =3.6465較加入後的 MSE = 3.6844來的小;因此模 型並不適合加入交互作用項x1*x2。
Table 2.2.1. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 3.9373 2.7898 1.41 0.1657
x1 1 2.4922 0.7658 3.25 0.0023 x2 1 0.5448 0.1748 3.12 0.0033
Table 2.2.2. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 2 790.4571 395.2285 29.72 <.0001 Error 41 545.1882 13.2973
Total 43 1335.6453
Root MSE 3.6465 R-Square 0.5918 Dependent Mean 24.9141 Adj R-Sq 0.5719
Coeff Var 14.6365
Table 2.2.3. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 9.2118 13.3850 0.69 0.4953
x1 1 1.1812 3.3430 0.35 0.7257 x2 1 0.2761 0.6895 0.40 0.6910 x1*x2 1 0.0647 0.1605 0.40 0.6890
Table 2.2.4. Analysis of Variance Dependent Mean 24.9141 Adj R-Sq 0.5630
Coeff Var 14.7883
不顯著;因此模型並不適合加入交互作用項x1*x3。
Table 2.2.5. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 2.3783 3.4820 0.68 0.4984
x1 1 3.5052 0.6422 5.46 <0.0001 x 3 1 2.8950 1.1938 2.43 0.0198
Table 2.2.6. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value
Model 2 745.8597 372.9298 25.92 <.0001 Error 41 589.7856 14.3850
Total 43 1335.6453
Root MSE 3.7928 R-Square 0.5584 Dependent Mean 24.9141 Adj R-Sq 0.5369
Coeff Var 15.2234
Table 2.2.7. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 21.0707 16.8103 1.25 0.2173
x1 1 -1.8944 4.7943 -0.40 0.6948 x 3 1 -3.7462 5.9678 -0.63 0.5335 x1*x 3 1 1.8918 1.6647 1.14 0.2625
Table 2.2.8. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value
Model 3 764.3063 254.7688 17.84 <.0001 Error 40 571.3389 14.2835
Total 43 1335.6453
Root MSE 3.7794 R-Square 0.5722 Dependent Mean 24.9141 Adj R-Sq 0.5402
Coeff Var 15.1695
Figure 2.2.5 : Partial regression scatter plot Figure 2.2.6 : (x1*x4) contour plot
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 18.6245 6.5980 2.82 0.0073
x1 1 4.2397 0.6272 6.76 <0.0001 x4 1 -4.2397 0.9481 -1.73 0.0917
Table 2.2.10. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value
Model 2 706.9820 353.4910 23.05 <.0001 Error 41 628.6632 15.3333
Total 43 1335.6453
Root MSE 3.9158 R-Square 0.5293 Dependent Mean 24.9141 Adj R-Sq 0.5064
Coeff Var 15.7171
Table 2.2.11. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 -10.5373 40.7896 -0.26 0.7975
x1 1 12.2147 11.0244 1.11 0.2745 x4 1 2.6680 6.0178 0.44 0.6599 x1*x4 1 -1.1722 1.6178 -0.72 0.4729
Table 2.2.12. Analysis of Variance Source DF Sum of
Squares Mean Square F Value P-value
Model 3 715.1268 238.3756 15.37 <.0001 Error 40 620.5185 15.5130
Total 43 1335.6453
Root MSE 3.9387 R-Square 0.5354 Dependent Mean 24.9141 Adj R-Sq 0.5006
Coeff Var 15.8089
Figure 2.2.7 : Partial regression scatter plot Figure 2.2.8 : (x2*x3) contour plot
yˆ =−0.3064+0.8017x2 +3.3866x3 (2.2.7) yˆ =−2.1452+0.8998x2 +4.0175x3 −0.0333x2x3 (2.2.8)
我們從Figure 2.2.7 的偏回歸圖可看到,在x2已加入模型中的情況下再加入x 後的散佈狀3 況大致呈一直線,表示模型在x2解釋完後,x 的加入對模型依舊有解釋能力。由 Figure 2.2.83 看出x2與x 的 contour plot 並未呈曲線狀,交互作用並不顯著;而由 Table 2.2.13-2.2.16 看出3 對x2與x 此兩變數而言,未加入交互作用項3 x2*x 前,3 x2與x 的 p-value<0.01,兩參數估計3 值皆為顯著,但加入交互作用項x2*x 後,3 x2與x 及3 x2*x 的 p-value>0.01,參數估計值皆變3 為不顯著;未加入交互作用項x2*x 前的3 Radj2 =0.5573較加入後的Radj2 =0.5465來的大,解釋 力較高,而未加入交互作用項x2*x 前的3 MSE = 3.7082較加入後的 MSE = 3.7534來的小;因 此模型並不適合加入交互作用項x2*x3。
Table 2.2.13. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 -0.3064 3.6024 -0.09 0.9326
x2 1 0.8017 0.1394 5.75 <0.0001 x 3 1 3.3866 1.1358 2.98 0.0048
Table 2.2.14. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 2 771.8778 385.9389 28.07 <.0001 Error 41 563.7675 13.7504
Total 43 1335.6453
Root MSE 3.7082 R-Square 0.5779 Dependent Mean 24.9141 Adj R-Sq 0.5573
Coeff Var 14.8838
Table 2.2.15. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 -2.1452 14.2827 -0.15 0.8814
x2 1 0.8998 0.7499 1.20 0.2372 x 3 1 4.0175 4.8751 0.82 0.4148 x2*x 3 1 -0.0333 0.2504 -0.13 0.8947
Table 2.2.16. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 3 772.1276 257.3759 18.27 <.0001 Error 40 563.5177 14.0879
Total 43 1335.6453
Root MSE 3.7534 R-Square 0.5781 Dependent Mean 24.9141 Adj R-Sq 0.5465
Coeff Var 15.0653
Figure 2.2.9 : Partial regression scatter plot Figure 2.2.10 : (x2*x4) contour plot
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 4.4249 7.7735 0.57 0.5723
x2 1 0.9269 0.1491 6.22 <0.0001 x4 1 0.3328 0.9874 0.34 0.7378
Table 2.2.18. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value Pr > F
Model 2 651.5134 325.7567 19.52 <.0001 Error 41 684.1319 16.6861
Total 43 1335.6453
Root MSE 4.0849 R-Square 0.4878 Dependent Mean 24.9141 Adj R-Sq 0.4628
Coeff Var 16.3958
Table 2.2.19. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 -7.0722 29.1920 -0.24 0.8098
x2 1 1.5311 1.4853 1.03 0.3088 x4 1 2.0189 4.2423 0.48 0.6367 x2*x4 1 -0.0889 0.2174 -0.41 0.6848
Table 2.2.20. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 3 654.3615 218.1205 12.81 <.0001 Error 40 681.2838 17.0321
Total 43 1335.6453
Root MSE 4.127 R-Square 0.4899 Dependent Mean 24.9141 Adj R-Sq 0.4517
Coeff Var 16.5649
Figure 2.2.11 : Partial regression scatter plot Figure 2.2.12 : (x3*x4) contour plot
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 19.2708 8.4209 2.29 0.0273
x 3 1 5.5702 1.4646 3.80 0.0005 x4 1 -1.4529 1.1911 -1.22 0.2295
Table 2.2.22. Analysis of Variance Dependent Mean 24.9141 Adj R-Sq 0.2284
Coeff Var 19.6506
Table 2.2.23. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 24.9447 41.7954 0.60 0.5540
x 3 1 3.8297 12.6385 0.30 0.7634 x4 1 -3.8297 6.6353 -0.36 0.7242 x *3 x4 1 3.8297 2.0223 0.14 0.8904
Table 2.2.24. Analysis of Variance Source DF Sum of Dependent Mean 24.9141 Adj R-Sq 0.2094
Coeff Var 19.8899
Figure 2.3.1 : Scatterplot matrix for four regressor variables
4 3
2
1 0.433 2.9272 1.1954 2.378
6.5897
ˆ x x x x
y = + + + − (2.3.1)
我們由 Figure 2.3.2 大概發現x4與y 的相關係數散佈幾乎接近圓形,可看出x4與y 的相 關性非常低;而x1對y 以及x2對y 的相關係數散佈較接近一直線,可看出x1、x2與y 的相關 性較高;而x 對 y 的相關性則僅次於3 x1與x2。而從Table 2.3.1 的相關係數矩陣亦可看出此現 象 , 相 較 於 其 他 變 數 而 言 0.7036
,x1 =
ry 呈 現 高 度 正 相 關 , 可 知x1與 y 有線性關係;而 -0.0685
,x4 =
ry 呈現低度負相關,x4與y 之線性關係最低。
而由Table 2.3.2 我們可以發現 將四個解釋變數均放入的模型,除了x4的p-value>0.01 參數值 不顯著外,其他三個變數p-value 皆大於 0.01,參數值均顯著,在模型均具解釋能力。因此,
我們判斷x4也許應該從模型中剔除。
Table 2.3.1. correlation coefficient matrix y x1 x2 x 3 x4 y 1 0.7036 0.6974 0.4874 -0.0685 x1 0.7036 1 0.6585 0.3588 0.1622 x2 0.6974 0.6585 1 0.2827 -0.1516 x 0.4874 0.3588 0.28273 1 0.1887 x4 -0.0685 0.1622 -0.1516 0.1887 1
Table 2.3.2. Parameter Estimates
Variable DF Parameter Estimate Standard Error t Value P-value Intercept 1 6.5897 6.7021 0.98 0.3316 x1 1 2.3780 0.7756 3.07 0.0039 x2 1 0.4330 0.1755 2.47 0.0181 x 3 1 2.9272 1.0919 2.68 0.0107 x4 1 -1.1954 0.8940 -1.34 0.1889
Table 2.3.3. Analysis of Variance Source DF Sum of
Squares
Mean
Square F Value P-value
Model 4 882.8688 220.7172 19.01 <.0001
Error 39 452.7765 11.6097
Total 43 1335.6453
Root MSE 3.4073 R-Square 0.661 Dependent Mean 24.9141 Adj R-Sq 0.6262
Coeff Var 13.6762
Figure 2.3.3 : Scatterplot matrix for three regressor variables
Variable DF Parameter Estimate Standard Error t Value P-value Variance Inflation Intercept 1 -1.1916 3.3579 -0.35 0.7246 0
x1 1 2.0544 0.7441 2.76 0.0087 1.8727 x2 1 0.5179 0.1653 3.13 0.0032 1.7734 x3 1 2.6701 1.0853 2.46 0.0183 1.1528
Table 2.3.5. Analysis of Variance Source DF Sum of
第四節
綜合以上結果,我們可以看到,無論是單一解釋變數的簡單線性回歸模式、兩解釋變數 的複模式、討論加入交互作用項的兩解釋變數的複回歸模式及四個解釋變數均加入的回歸模 式,解釋變數x4在模型中的參數檢定均不顯著。而由相關係數矩陣與圖形也可發現,x4與y 的線性關係度很低。因此,我們判斷解釋變數x4應從模型中踢除。我們認為模型 2.3.2 為最 佳模型,下一章我們將對模型2.3.2 進行殘差分析診斷。