0
             Alloy 97-1-1-1                   Alloy AuCa        
Dentist Method  1500°F  1600°F  1700°F      1500°F  1600°F  1700°F

1        1      813      792     792          907    792     835
         2      782      698     665          1115   835     870
         3      752      620     835          847    560     585

2        1       715      803     813         858    907    882
         2       772      782    743          933    792    824
         3       835      715    673          698    734    681

3        1       743      627    752          858    762    724
         2       813      743    613          824    847    782
         3       743      681    743          715    824    681

4        1       792      743    762          894    792    649
         2       690      882    772          813    870    858
         3       493      707    289          715    813    312

5        1       707      698    715          772    1048   870
         2       803      665    752          824     933   835
         3       421      483    405          536     405   312

这是我对上述数据的 sas 代码:

data gold;

do dentist=1, 2, 3, 4, 5;
    do method=1, 2, 3;
        do alloy= 1,2;
           do temp=1500, 1600, 1700; 
              input y @@; output; 
           end;
          end;
        end;
    end;

cards;
813 792 792     907 792 835
782 698 665     1115 835 870
752 620 835     847 560 585

715 803 813     858 907 882
772 782 743     933 792 824
835 715 673     698 734 681

743 627 752     858 762 724
813 743 613     824 847 782
743 681 743     715 824 681

792 743 762     894 792 649
690 882 772     813 870 858
493 707 289     715 813 312

707 698 715     772 1048 870
803 665 752     824 933 835
421 483 405     536 405 312
;
ODS graphics on;
proc GLM data=gold;
class dentist method alloy temp;
model y=dentist|method|alloy|temp;
run; quit;

我哪里做错了?

这是输出的一部分:

The GLM Procedure
Dependent Variable: y 

    Source DF Sum of Squares Mean Square F Value Pr > F 
    Model  89 1891095.556     21248.265   .       . 
    Error  0  0.000             .     
    Total 89  1891095.556       

    R-Square Coeff Var Root MSE y Mean 
    1.000000  .        .        741.7778 

错误应该是 Residuals 75772.0 16 4735.7

残差/错误不应该为 0,因为整个代码都是错误的。:(

我还需要知道如何为上述代码创建交互图/图表。对我的代码的任何帮助将不胜感激。

4

1 回答 1

2

这是过拟合的经典例子。

您只有 90 个测量值,因此模型具有 89 个自由度 (DF)。为了适应这些,您正在使用

  • 1 次拦截
  • 加上不同牙医的 5 个因素,有一个约束:它们必须总和为 0,即 4 DF
  • 为方法加上 3 个因子,再次减去一个约束,即 2 DF
  • 加上牙医和方法组合的 15 个因素,必须满足以下 8 个约束条件。由于这些约束不是完全独立的,因此这将 DF 减少到只有 7 个,即您允许GLM8 个 DF
    • 对于每位牙医,所有方法的因子总和必须为 0,并且
    • 对于每种方法,所有牙医的因子总和必须为 0

等等。

简而言之,您允许该GLM过程选择 1 个截距加上 89 个其他 DF 以仅拟合 90 个值。GLM可以生成完全适合您的数据的模型。难怪模型没有错误!

为了更好地理解它:

引入与真实测量值略有不同的假测量值,例如这种方式

data gold;
do dentist=1, 2, 3, 4, 5;
    do method=1, 2, 3;
        do alloy= 1,2;
            do temp=1500, 1600, 1700; 
                input y @@; 
                output; 
                Y +.1 * rand('NORMAL', 0, 500);
                output; 
            end;
        end;
    end;
end;
cards;

现在你的输出可能看起来像

Source          DF      Sum of Squar    Mean Square     F Value    Pr > F      
Model           89      19556981.91     219741.37       1.45       0.0403      
Error           90      13643754.57     151597.27                                   
Corrected To    179     33200736.48                                                 
                                                                                    
R-Square        Coeff   Root MSE        y Mean                                      
0.589053        51.89   389.3549        750.2041                                    

(不完全是,因为我介绍了一些随机性) 确实,您仍然给出GLM一个截距和 89 个因子(DF)来选择,但是您要求它适合 180 个值(1 个截距和 179 个 DF)

你应该做什么

_(除非您要求牙医进行 90 次额外测量)是选择更简单的型号。我想你对评估牙医不感兴趣,而只对技术感兴趣,即方法、合金和温度,所以写

proc GLM data=gold;
    class dentist method alloy temp;
    model y=method|alloy|temp; ** <- nothing about dentists here **;
run; quit;

结果将是:

Dependent Variable: y                   
Source              DF      Sum of Squar    Mean Square     F Value     Pr > F
Model               17      905055.156      53238.539       3.89        <.0001
Error               72      986040.4        13695.006              
Corrected Total     89      1891095.556                            
                                                                                            
R-Square            Coeff Var   Root MSE        y Mean 
0.478588            15.77638    117.0257        741.7778 

这告诉您更简单的模型更多关于您的数字(均方 53238.539)而不是“错误”,它没有解释 _(均方 13695.006)极不可能(小于 0.01% 的可能性)这是偶然的。

输出的最后一部分

Source              DF      Type III SS     Mean Square     F Value         Pr > F      
method              2       593427.4889     296713.7444     21.67           <.0001      
alloy               1       105815.5111     105815.5111     7.73            0.0069      
method*alloy        2       54685.0889      27342.5444      2               0.1433      
temp                2       82178.0222      41089.0111      3               0.056       
method*temp         4       30652.4444      7663.1111       0.56            0.6927      
alloy*temp          2       21725.3556      10862.6778      0.79            0.4563      
method*alloy*temp   4       16571.2444      4142.8111       0.3             0.8754      

告诉你

  • 该方法极有可能产生影响(低于 0.01% 的概率高均方值是偶然的)
  • 我们有统计上显着的迹象表明合金有所作为(0.69% 的高均方值可能是偶然的)
  • 有迹象表明温度会有所不同(5.6% 的高均方值可能是偶然的),您最好在发布之前收集更多数据
  • 方法和合金之间可能存在相互作用,但需要更多的数据来研究它

这就是我从你的实验中得出的结论。

于 2016-04-24T13:55:57.900 回答