http://bbs.pinggu.org/thread-2142362-1-1.html
SAS中线性回归REG怎么输出标准化残差啊?output out=output r=residuals
student=sresiduals;
这样只能输出残差和学生化残差
查了sas的文档,也没找到相应的输出变量:
可以根据定义算:
第一种:
标准化残差=残差/(sig)
/这里的sig=Root
MSE
页面输出中有root mse这一项,可以用参数除以这项可以得到标准化残差
但是此种方法比较麻烦
第二种:
学生化残差=残差/[(1-hii)*sig]
/hii为杠杆值
output
out= student=student h=h; /h=
输出每个观测的杠杆值
学生化残差*(1-hii)=残差/sig
/即得到标准化残差
data ex;
input
y x;
cards;
33.35 1854
34.78 1857
36.22 1948
37.66 2017
39.09 2092
40.53 2197
41.76 2608
42.81 2937
43.9 3119
44.94 3654
;
run;
proc reg data=ex;
model y=x;
output out=res student=stu
h=h;
run;
quit;
data res;
set res;
std_res=stu*(1-h);
run;
sas中如何做出残差图
给你个示例程序:
ods html;
ods graphics on;
proc mixed;
class Family Gender;
model Height = Gender / residual;
random Family Family*Gender;
run;
ods graphics off;
ods html close;
这是使用ODS输出系统,直接将以身高为自变量,性别为因变量,进行mixed效应分析所得残差图输出为html格式。
以下是另外用回归方法作的残差图:
数据:
data Class;
input Name $ Height Weight Age @@;
datalines;
Alfred 69.0 112.5 14 Alice 56.5 84.0 13 Barbara 65.3 98.0 13
Carol 62.8 102.5 14 Henry 63.5 102.5 14 James 57.3 83.0 12
Jane 59.8 84.5 12 Janet 62.5 112.5 15 Jeffrey 62.5 84.0 13
John 59.0 99.5 12 Joyce 51.3 50.5 11 Judy 64.3 90.0 14
Louise 56.3 77.0 12 Mary 66.5 112.0 15 Philip 72.0 150.0 16
Robert 64.8 128.0 12 Ronald 67.0 133.0 15 Thomas 57.5 85.0 11
William 66.5 112.0 15
;
程序:
ods html;
ods graphics on;
proc reg data = Class;
model Weight = Height;
run;
quit;
ods graphics off;
ods html close;
图见插入图:
http://f.hiphotos.baidu.com/zhidao/wh=450,600/sign=afe3a135728b4710ce7af5c8f6feefcb/b90e7bec54e736d13a6cd51c9b504fc2d56269a2.jpg
-
提问者评价
-
谢谢你,我自己已经做出来了,看你回答得这么仔细,分就给你吧
加载中,请稍候......