SAS Annotated Output GLM

 

在使用SAS过程中,proc glm步输出离差平方和有4种算法,分别是SS1 SS2 SS3 SS4

下面文章介绍了其中SS3的具体计算步骤和例子。

This page shows an example of analysis of variance run through a general linear model (glm) with footnotes explaining the output. The data were collected on 200 high school students, with measurements on various tests, including science, math, reading and social studies. The response variable is writing test score (write), from which we explore its relationship with gender (female) and academic program (prog). The model examined has the main effects of female and program type, as well as their interaction. The dataset used in this page can be downloaded fromhttp://www.ats.ucla.edu/stat/sas/webbooks/reg/default.htm.

The syntax for the page is provided below. The class statement defines which variables are to be treated as categorical variables in the modelstatement. The model statement has the main effects of female and prog, as well as their interaction; the interaction is specified by taking the product of the two main effect terms. The option ss3 tells SAS we want type 3 sums of squares; an explanation of type 3 sums of squares is provided below.

proc glm data = "c:\temp\hsb2";
 class female prog;
 model write = female prog female*prog /ss3;
run; quit;The GLM Procedure

   Class Level Information

Class         Levels    Values
female             2    0 1
prog               3    1 2 3

Number of Observations Read         200
Number of Observations Used         200

Dependent Variable: write 

                                        Sum of
Source                      DF         Squares     Mean Square    F Value    Pr > F
Model                        5      4630.36091       926.07218      13.56    <.0001
Error                      194     13248.51409        68.29131
Corrected Total            199     17878.87500

R-Square     Coeff Var      Root MSE    write Mean
0.258985      15.65866      8.263856      52.77500

Source                      DF     Type III SS     Mean Square    F Value    Pr > F
female                       1     1261.853291     1261.853291      18.48    <.0001
prog                         2     3274.350821     1637.175410      23.97    <.0001
female*prog                  2      325.958189      162.979094       2.39    0.0946

Class Level Information

   Class Level Information

Class

a

        Levels

b

   Values

c

female             2    0 1
prog               3    1 2 3

Number of Observations Read

d

        200
Number of Observations Used

d

        200

a. Class - Underneath are the categorical (factor) variables, which were defined as such in the class statement. Had the categorical variables not been defined in the class statement and just entered in the model statement, the respective variables would be treated as continuous variables, which would be inappropriate.

b. Levels - Underneath are the respective number of levels (categories) of the factor variables defined in the class statement.

c. Values - Underneath are the respective values of the levels for the factor variables defined in the class statement.

d. Number of Observations Read and Number of Observations Used - This is the number of observations read and the number of observation used in the analysis. The Number of Observations Used may be less than the Number of Observations Read if there are missing values for any variables in the equation. By default, SAS does a listwise deletion of incomplete cases.


Model Information

Dependent Variable

e

: write  

                                        Sum of
Source

f

                     DF

g

        Squares

h

     Mean Square

i

   F Value

j

   Pr > F

j

Model                        5      4630.36091       926.07218      13.56    <.0001
Error                      194     13248.51409        68.29131
Corrected Total            199     17878.87500

R-Square

k

    Coeff Var

l

     Root MSE

m

    write Mean

n

0.258985      15.65866      8.263856      52.77500

Source

o

                     DF

p

    Type III SS

q

     Mean Square

r

   F Value

s

   Pr > F

s

female                       1     1261.853291     1261.853291      18.48    <.0001
prog                         2     3274.350821     1637.175410      23.97    <.0001
female*prog                  2      325.958189      162.979094       2.39    0.0946

e. Dependent Variable - This is the dependent variable in our glm model.

f. Source - Underneath are the sources of variation of the dependent variable. There are three parts, Model, Error, and Corrected Total. With glm, you must think in terms of the variation of the response variable (sums of squares), and partitioning this variation. The variation in the response variable, denoted by Corrected Total, can be partitioned into two unique parts. The first partition, Model, is the variance in the response accounted by our model (female prog female*prog). The second source, Error, is the variation not explained by the Model. These two sources, the explained (Model), and unexplained (Error), add up to the Corrected Total, SSCorrected Total = SSModel + SSError.

The term "Corrected Total" is called such, as compared to "Total", or more correctly, "Uncorrected Total," because the "Corrected Total" adjusts the sums of squares to incorporate information on the intercept. Specifically, the Corrected Total is the sum of the squared difference between the response variable and the mean of the response variable, whereas the Uncorrected Total is the sum of the squared values of just the response variable.

g. DF - These are the degrees of freedom associated with the respective sources of variance. As with the additive nature of the sums of squares, the degrees of freedom are also additve, DFCorrected Source = DFModel + DFError. The DFCorrected Total has N-1 degrees of freedom, where N is the total sample size. See DF, superscript p, for the calculation of the DF for each individual predictor variable, which add up to DFModel. Hence, DFError=DFCorrected Total - DFModel. The DFModel and DFError define the parameters of the F-distribution used to test F Value, superscript j.

h. Sum of Squares - These are the sums of squares that correspond to the three sources of variation. 
SSModel - The Model sum of squares is the squared difference of the predicted value and the grand mean summed over all observations. Suppose our model did not explain a significant proportion of variance, then the predicted value would be near the grand mean, which would result with a small SSModel, and SSError would nearly be equal to SSCorrected Total
SSError - The Error sum of squares is the squared difference of the observed value from the predicted value summed over all observations. 
SSCorrected Total - The Corrected Total sum of squares is the squared difference of the observed value from the grand mean summed over all observations.

i. Mean Square - These are the Mean Squares (MS) that correspond to the partitions of the total variance. The MS is defined as SS/DF.

j. F Value and Pr > F - These are the F Value and p-value, respectively, testing the null hypothesis that the Model does not explain the variance of our response variable. F Value is computed as MSModel / MSError, and under the null hypothesis, F Value follows a central F-distribution with numerator DF = DFModel and denominator DF =DFError. The probability of observing an F Value as large as, or larger, than 13.56 under the null hypothesis is < 0.0001. If we set our alpha level at 0.05, our willingness to accept a Type I error, we'd reject the null hypothesis and conclude that our model explains a statistically significant proportion of the variance.

k. R-Square - This is the R-Square value for the model. R-Square defines the proportion of the total variance explained by the Model and is calculated as R-Square = SSModel/SSCorrected Total = 4630.36/17878.88=0.259.

l. Coeff Var - This is the Coefficient of Variation (CV). The coefficient of variation is defined as the 100 times root MSE divided by the mean of response variable; CV = 100*8.26/52.775 = 15.659. The CV is a dimensionless quantity and allows the comparison of the variation of populations.

m. Root MSE - This is the root mean square error. It is the square root of the MSError and defines the standard deviation of an observation about the predicted value.

n. write Mean - This is the grand mean of the response variable.

o. Source - Underneath are the variables in the model. Our model has femaleprog, and the interaction of female and prog. The interaction disallows the effect of, say, prog, over the levels of female to be additive. Also, our model follows the hierarchical principal, i.e., if an interaction term is in the model (female*prog), the lower order terms (female and prog) must be included. Further, when there is a significant interaction in the model, the main effects (the lower order terms) are difficult to interpret. If the interaction term is not statistically significant, some would advise dropping the term and rerunning the model with just the main effects, so that the main effects would have an unambiguous meaning. The traditional anova approach would leave the nonsignificant interaction in the model and interpret the main effects in the normal manner. If the interaction term is found statistically significant, one would leave the model as is and evaluate the simple main effects.

p. DF - These are the degrees of freedom for the individual predictor variables in the model. From the class level information section, the lower order term DF is given by the number of levels minus one. For example, female as two levels, therefore DFfemale = 2-1=1. Also, prog has three levels and DFprog = 3-1=2. For the interaction term, DFfemale*prog = DFprog* DFfemale = 1*2 =2. The DF of the predictor variables, along with the DFError, define the parameters of the F-distribution used to test the significance of F Value, superscript s.

q. Type III SS - These are the type III sum of squares, which are referred to as partial sum of squares. For a particular variable, say female, SSfemaleis calculated with respect to the other variables in the model, prog and female*prog. Also, we showed earlier that SSCorrected Total = SSModel + SSError, and we might expect that SSModel = SSfemale + SSprog+ SSprog*female; however, this is generally not the case (this is only true for a balanced design).

r. Mean Square - These are the mean squares for the individual predictor variables in the model. They are calculated as SS/DF, and along MSError, they are used to calculate F Value, superscript s.

s. F Value and Pr > F - These are the F Value and p-value, respectively, testing the null hypothesis that an individual predictor in the model does not explain a significant proportion of the variance, given the other variables are in the model. F Value is computed as MSSource Var / MSError. Under the null hypothesis, F Value follows a central F-distribution with numerator DF = DFSource Var, where Source Var is the predictor variable of interest, and denominator DF =DFError. Following the point made in Source, superscript o, we focus only on the interaction term.
female*prog - This is the F Value and p-value testing the interaction of female and prog on the response variable, given the other variables are in the model. The probability of observing an F Value, as large as, or larger, than 2.39 under the null hypothesis that there is not an interaction of femaleandprog, given the other variables are in the model, is 0.0946. If we set our alpha level at 0.05, the probability of a Type I error, we would fail to reject the null hypothesis that female and prog do not interact. Based on this finding, some would advise rerunning the model without the interaction term, including only the main effects in the model (and the intercept). This would in turn permit a valid interpretation of the main effects of female and prog.

SAS Annotated Output GLM的更多相关文章

  1. R语言统计分析应用与SAS、SPSS的比较

    能够用来做统计分析的软件和程序很多,目前应用比较广泛的包括:SPSS, SAS.R语言,Matlab,S-PLUS,S-Miner等.下面我们来看一下各应用的特点: SPSS: 最简单的,都是菜单操作 ...

  2. C#生成DBF文件

    C# 生成DBF,无需注册Microsoft.Jet.OLEDB. namespace ConsoleApplication { class Program { static void Main(st ...

  3. YOLO object detection with OpenCV

    Click here to download the source code to this post. In this tutorial, you’ll learn how to use the Y ...

  4. LOGIT REGRESSION

    Version info: Code for this page was tested in SPSS 20. Logistic regression, also called a logit mod ...

  5. .NET使用FastDBF写入DBF

    FastDBF源代码地址:https://github.com/SocialExplorer/FastDBF 第一步在解决方案中新建一个类库的项目:取名为SocialExplorer.FastDBF ...

  6. SAS笔记

    SAS基础知识 SAS里面的PROC一览 The ACECLUS Procedure : 聚类的协方差矩阵近似估计(approximate covariance estimation for clus ...

  7. SAS数据步与过程步,数据步语句

    SAS数据步与过程步,数据步语句http://www.biostatistic.net/thread-2045-1-1.html  ---转载---原文作者:biostar(出处: 生物统计家园) 数 ...

  8. SAS基础 -- SAS编程入门

    SAS语言 -- 简介   SAS语言是一种专用的数据管理与分析语言,它提供了一种完善的编程语言.类似于计算机的高级语言,SAS用户只需要熟悉其命令.语句及简单的语法规则就可以做数据管理和分析处理工作 ...

  9. SAS零散知识总结

    1,变量名命名规范:以字母或者下划线开始,可包含字母.下划线.数字,且不超过32个字符: 2,INFILE用于读取外部数据文件,一般于FILENAME(和LIBNAME用户一致,但路径要精确到文件名( ...

随机推荐

  1. href="#"会导致location.replace(location.href);脚本不工作

    我们经常这样:<a onclick="xxx" href="#" 其实这不是一个好习惯,当点下这个连接后,主页面的URL后面会加个#号,这样就会导致很多J ...

  2. 面向生产环境的大集群模式安装Hadoop

    一.实验说明 1.本实验将使用DNS而不是hosts文件解析主机名: 2.使用NFS共享密钥文件,而不是逐个手工拷贝添加密钥: 3.复制Hadoop时使用批量拷贝脚本而不是逐台复制. 测试环境: Ho ...

  3. shell基础二十篇 一些笔记

    shell基础二十篇 转自 http://bbs.chinaunix.net/thread-452942-1-1.html 研讨:Bash 内建命令 read (read命令更具体的说明见博客收藏的一 ...

  4. EF查询分页

    static List<T> GetPageList(Func<T,bool> whereLambda,Func<T,object> orderLambda,int ...

  5. Spring AOP:面向切面编程,AspectJ,是基于spring 的xml文件的方法

    导包等不在赘述: 建立一个接口:ArithmeticCalculator,没有实例化的方法: package com.atguigu.spring.aop.impl.panpan; public in ...

  6. asp.net 查询,导出

    using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using S ...

  7. 基本的MFC多线程

    多线程程序我本来是能够来写的.但是由于在图像处理的过程中,对于这方面知识使用的比较少,造成重复忘记的情况.这里再次进行整理学习,特别注重和“图像处理”理清关系,为下一步使用奠定基础. 这里实现的是工作 ...

  8. js遍历

    最近看了一些不错的文章关于js遍历+js数组去重+文件上传的,今天也自己动手试了试.有好多之前不是细节不是很了解.正好学习了. map函数也是 类似这样的对象还有函数的属性arguments对象,当然 ...

  9. ie兼容整理

    那里面有东西要长研究 ie bug集合关于如何给各种浏览器打bug,可查询:browser hacks 几篇处理ie问题的帖子,帖子1

  10. 【Java】hashcode()和equals()

    大家知道,在集合中判断集合中的两个元素是否相同,依赖的是hashcode()和equals()两个方法. > 一个简单的实验 public class Teacher { private Int ...