楼主: luohuaping
7362 7

求助:SAS产生多元正态分布的随机数程序哪里错误? [推广有奖]

  • 0关注
  • 0粉丝

高中生

30%

还不是VIP/贵宾

-

威望
0
论坛币
21 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
261 点
帖子
38
精华
0
在线时间
10 小时
注册时间
2009-1-15
最后登录
2020-5-12

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
本人需要生成多元正态分布的随机数,在其他地方看到了一个程序,但是运行后提示错误。本人刚刚接触iml过程,对其中的运算不是很了解,故求助于高手看一下哪里出现了错误,怎样能够正确的运行程序。不甚感激!
       题意是要生成1000组相关系数均为0.3的服从多元正态分布的随机向量(X,Y,Z),其中随机变量X~N(0,1),y~N(10,2),Z~ N(20,3)。

程序如下:
proc iml;
R={1.00 0.30 0.30,
   0.30 1.00 0.30,
   0.30 0.30 1.00};
S={1 0 0,
   0 2 0,
   0 0 3};
E=S*R*S;
u={0,10,20};
do i=1 to 1000;
zl=RANNOR(0);
z2=RANNOR(0);
z3=RANNOR(0);
C=root(E);
xi=C`*(z1//z2//z3)+u;
m=m//xi`;
end ;
ERROR: (execution) Matrices do not conform to the operation.(运行窗口提示)
create example4 var{x y z};
append from m ;
run;
ERROR: Number of columns in m does not match with the number of variables in the data set.(运行窗口提示)
二维码

扫码加我 拉你入群

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

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

关键词:多元正态分布 正态分布 随机数 Variables EXECUTION 求助 程序 SAS 多元正态分布 随机数

沙发
jingju11 发表于 2009-12-2 02:29:11 |只看作者 |坛友微信交流群
zl=RANNOR(0);
zl should be z1; that is ZL ^= Z1

使用道具

藤椅
luohuaping 发表于 2009-12-2 18:35:56 |只看作者 |坛友微信交流群
谢谢jingju11,我刚才改了一下,但是还是运行不了。
最后提示NOTE: Module MAIN is undefined in IML; cannot be RUN.
郁闷!

使用道具

板凳
jingju11 发表于 2009-12-2 21:48:58 |只看作者 |坛友微信交流群
3# luohuaping

Replace

run;
by

  1. quit;
复制代码
in the last line of your code to terminate the PROC IML.
NOTE: Module MAIN is undefined in IML; cannot be RUN.
the note in the log likely results from
In PROC IML, the RUN statement is used to execute/run a module.
when a RUN statement is submitted but without giving the name of a module, the RUN statement takes the name of the module as MAIN and tries to run it.
but apparently it fails in your case.

使用道具

报纸
bobguy 发表于 2009-12-4 08:42:12 |只看作者 |坛友微信交流群
luohuaping 发表于 2009-12-1 20:27
本人需要生成多元正态分布的随机数,在其他地方看到了一个程序,但是运行后提示错误。本人刚刚接触iml过程,对其中的运算不是很了解,故求助于高手看一下哪里出现了错误,怎样能够正确的运行程序。不甚感激!
       题意是要生成1000组相关系数均为0.3的服从多元正态分布的随机向量(X,Y,Z),其中随机变量X~N(0,1),y~N(10,22),Z~ N(20,32)。

程序如下:
proc iml;
R={1.00 0.30 0.30,
   0.30 1.00 0.30,
   0.30 0.30 1.00};
S={1 0 0,
   0 2 0,
   0 0 3};
E=S*R*S;
u={0,10,20};
do i=1 to 1000;
zl=RANNOR(0);
z2=RANNOR(0);
z3=RANNOR(0);
C=root(E);
xi=C`*(z1//z2//z3)+u;
m=m//xi`;
end ;
ERROR: (execution) Matrices do not conform to the operation.(运行窗口提示)
create example4 var{x y z};
append from m ;
run;
ERROR: Number of columns in m does not match with the number of variables in the data set.(运行窗口提示)
SAS iml has a random multivariate normal call routine vnormal.

Here is an example,

proc iml;
n=1000;
et=repeat(0,n,3);
mu   = { 0, 0,0 };
corr= { 1  0.3  0.3,
            0.3 1 0.3,
             0.3 0.3 1};

  call vnormal(et, mu, corr, n, 89010);

  et[ ,1]=et[ ,1]       + 0;
  et[ ,2]=22*et[ ,2] + 10;
  et[ ,3]=32*et[ ,3] + 20;
  norm_err=et;
  create a from norm_err;
  append from norm_err;

quit;

proc corr data=a;
var col1 col2 col3;
run;

使用道具

地板
luohuaping 发表于 2009-12-26 18:52:19 |只看作者 |坛友微信交流群
已经解决!谢谢各位!

使用道具

7
木子若 发表于 2012-10-22 15:23:30 |只看作者 |坛友微信交流群
楼主,请问这个问题怎么解决的?是不是要加上iml模块?

使用道具

8
木子若 发表于 2012-10-22 16:01:16 |只看作者 |坛友微信交流群
iml模块怎么加上?楼主有带有iml的sas安装文件吗?能不能给传一份,不胜感激!

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-25 21:12