SAS中文论坛

标题: 请问proc reg中的weight选项作用是? [打印本页]

作者: shiyiming    时间: 2008-1-2 15:20
标题: 请问proc reg中的weight选项作用是?
实在是不明白这个回归过程中weight选项是用来干什么的,以及proc univariate中也有这个权重选项,基本上每个proc中都有这个选项,他们的作用是什么呢?谢谢,请指教 。
作者: shiyiming    时间: 2008-1-12 13:42
标题: Re: 请问proc reg中的weight选项作用是?
在线性回归中,如果Y的方差随着X值的增加而变大,则需要用Weighted regression. 具体可以查阅Weighted linear regression 的资料 。下面是一个例子:
data cal;
input y x;
datalines;
   77.0   16.0
   70.0   14.0
   85.0   22.0
   50.0   10.0
   62.0   14.0
   70.0   17.0
   55.0   10.0
   63.0   13.0
   88.0   19.0
   57.0   12.0
   81.0   18.0
   51.0   11.0
;
run;
proc reg data=cal;
model y=x;
output out=estimation r=r p=pl;
plot r.*x;
run;
data estimation2;
set estimation;
absr=abs(r);
absr2=absr**2;
run;
proc reg data=estimation2;
model absr=x;
plot absr*x;
output out=weightout p=abs_w;
run;
data weightout2;
set weightout;
w=abs_w**(-2);
run;
proc print weightout2; run;
proc reg data=weightout2;
var pl w;
model y=x/clb;
weight w;
output out=iterat r=resid;
run;
proc print data=iterat; run;
data iterat2;
set iterat;
absresid=abs(resid);
run;
proc reg data=iterat2;
model absresid=x;
output out=iteratweight p=iteratew;
run;
data iterateweight2;
set iteratweight;
w2=iteratew**(-2);
run;




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2