楼主: 3qsir
3320 10

AboutPROC MODEL :有关样本外预测值(y_hat)递迭摆置的问题 [推广有奖]

  • 2关注
  • 1粉丝

副教授

52%

还不是VIP/贵宾

-

威望
0
论坛币
13606 个
通用积分
27.0809
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
71836 点
帖子
367
精华
0
在线时间
931 小时
注册时间
2011-5-18
最后登录
2021-3-6

楼主
3qsir 发表于 2014-3-9 17:51:05 |AI写论文
30论坛币
I using insample file a by(group) to estimate a0 and a1 coef. and used those to predict threey (y_hate) under given outsample d, how to put those 3 y_hat  rooling outcom like below:
group

199111

199112

199201

199202

1

yhat(1,1)yhat(1,2)yhat(1,3)

2

yhat(2,1)yhat(2,2)yhat(2,3)

PROC MODEL DATA= a ;

        y=a0+a1*x;
FIT y / OUTEST=b1 ;
SOLVE y / DATA=d ESTDATA=b1 OUT=c1 ;
BY group;
RUN;
PROC PRINT DATA=c1 (DROP _MODE_  _ERRORS_) ;
RUN;
insample a.file
MONgroup y    x

199101

1

1

-3.45

199102

1

2

8.05

199103

1

2

-0.66

199104

1

3

0.19

199105

1

4

-0.54

199106

1

3

-5.59

199107

1

6

1.21

199108

1

7

-0.95

199109

1

2

6.54

199102

2

9

8.05

199103

2

8

-0.66

199104

2

7

0.19

199105

2

4

-0.54

199106

2

6

-5.59

199107

2

5

1.21

199108

2

4

-0.95

199109

2

3

6.54

199110

2

2

-2.33                                   


out sample file d:
MON group       x

199110

1

2.33

199111

1

9

199112

1

7

199111

2

9

199112

2

7

199201

2

2

I hope results:


group

199111

199112

199201

199202

1

yhat(1,1)yhat(1,2)yhat(1,3)

2

yhat(2,1)yhat(2,2)yhat(2,3)
     

最佳答案

intheangel 查看完整内容

data a; input mon group x; cards; 199110 1 2.33 199111 1 9 199112 1 7 199111 2 9 199112 2 7 199201 2 2 ; run; proc transpose data=a out=b(drop=_name_); by group; id mon; run; proc print data=b noobs; run; group _199110 _199111 _199112 _199201 1 2.33 9 7 . 2 . 9 7 2 是要这个结果么?
关键词:样本外预测值 About model Bout mode file

沙发
intheangel 学生认证  发表于 2014-3-9 17:51:06


data a;
input mon group x;
cards;
199110 1 2.33
199111 1 9
199112 1 7
199111 2 9
199112 2 7
199201 2 2
;
run;

proc transpose data=a out=b(drop=_name_);
by group;
id mon;
run;

proc print data=b noobs;
run;


group _199110 _199111 _199112 _199201
1    2.33    9     7    .
2      .       9     7    2



是要这个结果么?
已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
admin_kefu + 100 热心帮助其他会员
3qsir + 5 + 5 + 5 热心帮助其他会员

总评分: 论坛币 + 100  学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

藤椅
intheangel 学生认证  发表于 2014-3-9 20:35:50
data a;
input mon group x;
cards;
199110 1 2.33
199111 1 9
199112 1 7
199111 2 9
199112 2 7
199201 2 2
;
run;

proc transpose data=a out=b(drop=_name_);
by group;
id mon;
run;

proc print data=b noobs;
run;


group _199110 _199111 _199112 _199201
1    2.33    9     7    .
2      .       9     7    2


是要这个结果么?


我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

板凳
3qsir 发表于 2014-3-9 20:51:08
NO! NO!
y regress on x (using in sample to forecas outsample y_hat)
PROC MODEL DATA= a ;
        y=a0+a1*x;
FIT y / OUTEST=b1 ;
SOLVE y / DATA=d ESTDATA=b1 OUT=c1 ;
BY group;
RUN;

报纸
3qsir 发表于 2014-3-9 20:58:04
This is correct that i hope results :
group 1----->199110 to 199112
group 2----->199111 to 199201
-----------------------------------------------------
group        199110        199111        199112        199201
1        yhat(1,1)        yhat(1,2)        yhat(1,3)       
2                yhat(2,1)        yhat(2,2)        yhat(2,3)

地板
intheangel 学生认证  发表于 2014-3-9 21:01:56
那你只能预测199110,199111,199112的group1 的y
和199111,199112,199201的group2的y吧
1999202的怎么预测?
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

7
intheangel 学生认证  发表于 2014-3-9 21:07:40
data a;
input mon group y x @@;
cards;
199101 1 1 -3.45
199102 1 2 8.05
199103 1 2 -0.66
199104 1 3 0.19
199105 1 4 -0.54
199106 1 3 -5.59
199107 1 6 1.21
199108 1 7 -0.95
199109 1 2 6.54
199102 2 9 8.05
199103 2 8 -0.66
199104 2 7 0.19
199105 2 4 -0.54
199106 2 6 -5.59
199107 2 5 1.21
199108 2 4 -0.95
199109 2 3 6.54
199110 2 2 -2.33  
;
run;

data d;
input month group x@@;
cards;
199110 1 2.33
199111 1 9
199112 1 7
199111 2 9
199112 2 7
199201 2 2
;
run;


PROC MODEL DATA= a ;
        y=a0+a1*x;
                by group;
FIT y / OUTEST=b1 ;
SOLVE y / DATA=d ESTDATA=b1 OUT=c1 ;
BY group;
RUN;

data c2(keep=month group y);
merge d c1;
by group;
run;


proc transpose data=c2 out=after(drop=_name_);
by group;
id month;
proc print noobs;
run;


是这样么?
我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

8
3qsir 发表于 2014-3-10 09:02:40
Intheangel :Can you check the codes, I construct a macro program under your giving codes,
because I have lots of “a” file : totala1(start)---->totala135(end)
                      lots of   “d” file : totald1(start)---->totald135(end)
I hope all results of  “afters” file : after1(start)---->after135(end)
--------------------------------------------------
%macro country(cstart,cend)
%Do i=&cstart %to &cend;
procimportdatafile=”c:\temp\toatala.&i.csv”
out=a.&i
        dbms=csv
        replace;
getnames=no;
run;
procimportdatafile=”c:\temp\toatalb.&i.csv”
out=d.&i
        dbms=csv
        replace;
getnames=no;
run;
PROCMODEL DATA= a.&i ;
         y=a0+a1*x;
by group;
FIT y / OUTEST=b.&i ;
SOLVE y / DATA=d.&i ESTDATA=b.&i OUT=c.&i ;
BY group;
RUN;
Data cc.&i(keep=month group y);
Merge d.&i c.&i;
by group;
run;
proctranspose data=cc.&I out=after.&i(drop=_name_);
by group;
id month;
procexport data= after&i
outfile="c:\temp\after&i.csv"
dbms=csv
replace;
run;
%end;
%mend country;
Good luck today !

9
intheangel 学生认证  发表于 2014-3-10 14:52:50
3qsir 发表于 2014-3-10 09:02
Intheangel :Can you check the codes, I construct a macro program under your giving codes,
because I ...
%macro country(cstart,cend)
%Do i=&cstart %to &cend;
proc import datafile=”c:\temp\toatala&i.csv”
out=a_&i
        dbms=csv
        replace;
getnames=yes;
run;
proc import datafile=”c:\temp\toatalb&i.csv”
out=d_&i
        dbms=csv
        replace;
getnames=no;
run;
PROC MODEL DATA= a_&i;
         y=a0+a1*x;
by group;
FIT y / OUTEST=b_&i ;
SOLVE y / DATA=d_&i ESTDATA=b_&i OUT=c_&i ;
BY group;
RUN;

Data cc_&i(keep=month group y);
Merge d_&i c_&i;
by group;
run;
proctranspose data=cc_&i out=after_&i(drop=_name_);
by group;
id month;
proc export data= after_&i
outfile="c:\temp\after&i.csv"
dbms=csv
replace;
run;
%end;
%mend country;




Without your resource file ,i can not sure about the code is right or not.
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
3qsir + 3 + 5 + 5 热心帮助其他会员

总评分: 学术水平 + 3  热心指数 + 5  信用等级 + 5   查看全部评分

我是一只瘦瘦的小猪~~~
╭︿︿︿╮
{/-◎◎-/}
( (oo) )
  ︶︶︶

10
3qsir 发表于 2014-3-10 23:07:22
Still ERROR.try it !
Can your card  "data a" save as c:\temp\totala1.csv and your card "data d" ---->c: \temp\otald1.csv
then excute %macro(1,2)
--------------------------------------
ERROR: Expected semicolon not found.  The macro will not be compiled.
ERROR: A dummy macro will be compiled.
15         %macro country(cstart,cend)
16          %Do i=&cstart %to &cend;
17          proc import datafile=”c:\temp\toatala&i.csv”
18          out=a_&i
19                  dbms=csv
20                  replace;
21          getnames=yes;
22          run;
23          proc import datafile=”c:\temp\toatalb&i.csv”
24          out=d_&i
25                  dbms=csv
26                  replace;
27          getnames=no;
28          run;
29          PROC MODEL DATA= a_&i;
30                   y=a0+a1*x;
31          by group;
32          FIT y / OUTEST=b_&i ;
33          SOLVE y / DATA=d_&i ESTDATA=b_&i OUT=c_&i ;
34          BY group;
35          RUN;
36         
37         Data cc_&i(keep=month group y);
38          Merge d_&ic_&i;
39          by group;
40          run;
41          proctranspose data=cc_&i out=after_&i(drop=_name_);
42          by group;
43          id month;
44          proc export data= after_&i
45          outfile="c:\temp\after&i.csv"
46          dbms=csv
47          replace;
48          run;
49          %end;
ERROR: There is no matching %DO statement for the %END. This statement will be ignored.
50          %mend country;
51         % country(1,2)
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

52         
53         GOPTIONS NOACCESSIBLE;

54         %LET _CLIENTTASKLABEL=;
55         %LET _CLIENTPROJECTPATH=;
56         %LET _CLIENTPROJECTNAME=;
57         %LET _SASPROGRAMFILE=;
58         
59         ;*';*";*/;quit;run;
60         ODS _ALL_ CLOSE;
61         
62         
63         QUIT; RUN;
---------------------------------------

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-24 12:22