sas中如何做出残差图

2025-05-21 01:07:31
推荐回答(3个)
回答1:

给你个示例程序: 

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;

图见插入图:

回答2:

proc reg data=temp;***your data set
model y=x1-x5/p;
plot residual. * x1='*';
title '以x1为横轴的残插图';
run;

不知道你要的数据表是什么,而且残插图是2维,仅能看到一个变量和残差的2维图像。

你试试,不行可以邮件我,不过分要给我哈:)

回答3:

proc reg data=yourfile;
model y=x1 x2 x3 x4 x5;
title 'residual vs predcited';
plot residual.*predicted.;
run;