全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3208 5
2010-03-29
我想在SAS程序中对数据按照ID的不同做多次回归,然后取得每次回归后的R^2,再对R^2进行统计分析,可是我不知道如何在REG命令后获得R^2的值。
哪位大侠能够指点一下?
十分谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-3-30 07:43:38
rick007007 发表于 2010-3-29 16:10
我想在SAS程序中对数据按照ID的不同做多次回归,然后取得每次回归后的R^2,再对R^2进行统计分析,可是我不知道如何在REG命令后获得R^2的值。
哪位大侠能够指点一下?
十分谢谢!
Use edf option with outest option on reg statement. See example below.


data t1;
   do i = 1 to 10;
      x=rannor(0);
      y=1+1*x+rannor(0);
      output;
    end;
run;

proc reg data=t1 outest=t2 edf;
model y=x;
run;
quit;

proc print data=t2;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-3-30 08:50:43
楼上可能没理解楼主的意思
data a;seta;i=_n_;
%macro ff;
%do i=1 %to 1895;
proc reg data=a(where =(&i le a le &i+9)) outest=b edf;/ *输出拟合优度*/
model rm=rp;
run;
proc append base=cj
data=bf orce;
run;
%end;
...
...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-3-31 11:37:13
多谢楼上两位的解答! 因为对SAS语言掌握有限,楼上的看的不是很明白。我自己找到一种方法,将拟合优度作为变量输出。
proc reg  noprint data=final outest=mfinal;
model fret=mret / SELECTION=RSQUARE;

data mfinal; set mfinal;
alpha=intercept;
beta =mret;
rsq = _rsq_;
keep alpha beta rsq;

关键是两点,一是 / SELECTION=RSQUARE; 将拟合优度输出; 二是将outest对应的结果集中找到拟合优度的变量名称, 也就是 _rsq_; 按照此法,如果知晓结果中变量对应的名称,就可以将所有的输出结果保留。如何知道输出结果的所有变量名称,还请高手指点一二。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-2 08:50:21
sas的帮助里面有所有的变量名称
SAS/STAT® 9.2 User’s Guide
The REG Procedure

_IN_, the number of regressors in the model not including the intercept
 _P_, the number of parameters in the model including the intercept, if any
 _EDF_, the error degrees of freedom
 _SSE_, the error sum of squares, if the SSE option is specified
 _MSE_, the mean squared error, if the MSE option is specified
 _RSQ_, the R2 statistic
 _ADJRSQ_, the adjusted R2, if the ADJRSQ option is specified
 _CP_, the Cp statistic, if the CP option is specified
 _SP_, the Sp statistic, if the SP option is specified
 _JP_, the Jp statistic, if the JP option is specified
 _PC_, the PC statistic, if the PC option is specified
 _GMSEP_, the GMSEP statistic, if the GMSEP option is specified
 _AIC_, the AIC statistic, if the AIC option is specified
 _BIC_, the BIC statistic, if the BIC option is specified
 _SBC_, the SBC statistic, if the SBC option is specified
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-4-3 09:27:56
十分感谢楼上的热心指点
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群