全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2492 4
2011-09-17
请问各位有谁知道蒙特卡洛模拟方法在SPSS和SAS中的操作啊?有资料或程序的分享一下!谢谢!!
二维码

扫码加我 拉你入群

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

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

全部回复
2011-9-18 04:13:56
options formdlim='-' pageno=min nodate;
DATA normal1; drop obs I;
* randomly sample 2,500,000 scores from a normal population which has a mean of 100 and a standard deviation of 15;
* arrange these in a matrix with 25 columns and 100,000 rows;
do obs=1 to 100000;
array Ys[25] Y1-Y25;
do I = 1 to 25;
Ys[I]=100+15*NORMAL(0);
end; output; end;
proc univariate plot normal; var Y1;
title 'One Sample of 100,000 scores from Normal Distribution'; run;
run;
*************************************************************************;
data normal2; set normal1;
*  compute sample mean, standard deviation, variance, z, and t on 100,000 samples with N = 9 and 100,000 samples with N = 25 ;
*  the z and the t  test the null hypothesis that the population mean is 100 ;
mean9 = mean(of Y1-Y9);     mean25 = mean(of Y1-Y25);
std9 = std(of Y1-Y9);      std25=std(of Y1-Y25);
var9 = std9*std9;      var25 = std25*std25;
Z9 = (mean9 - 100)/5;      Z25 = (mean25 - 100)/3;
T9 = (mean9 - 100)/(std9/3);     T25 = (mean25 - 100)/(std25/5);
Type1_N9 = 'No ';
If ABS(T9)GE 2.306 then Type1_N9 = 'Yes';
Type1_N25 = 'No ';
If ABS(T25)GE 2.064 then Type1_N25 = 'Yes';

proc freq; tables Type1_N9 Type1_N25;
title 'Frequency of Type I Errors';

proc univariate noprint;
*  to look at the distribution of one sample of 100,000 of these scores ;
output out=normal3
mean=mean_mean9 mean_var9 mean_std9 mean_Z9 mean_T9
mean=mean_mean25 mean_var25 mean_std25 mean_Z25 mean_T25
median=med_mean9 med_var9 med_std9 med_Z9 med_T9
median=med_mean25 med_var25 med_std25 med_Z25 med_T25
std=std_mean9 std_var9 std_std9 std_Z9 std_T9
std=std_mean25 std_var25 std_std25 std_Z25 std_T25
skewness=g1_mean9 g1_var9 g1_std9 g1_Z9 g1_T9
skewness=g1_mean25 g1_var25 g1_std25 g1_Z25 g1_T25
kurtosis=g2_mean9 g2_var9 g2_std9 g2_Z9 g2_T9
kurtosis=g2_mean25 g2_var25 g2_std25 g2_Z25 g2_T25
min=min_mean9 min_var9 min_std9 min_Z9 min_T9
min=min_mean25 min_var25 min_std25 min_Z25 min_T25
max=max_mean9 max_var9 max_std9 max_Z9 max_T9
max=max_mean25 max_var25 max_std25 max_Z25 max_T25;
var mean9 var9 std9 Z9 T9 mean25 var25 std25 Z25 T25; run;
*************************************************************************;
data normal4; set normal3;
proc print; var mean_mean9 med_mean9 std_mean9 g1_mean9 g2_mean9 min_mean9 max_mean9;
title 'Normal Population, Distribution of Sample Means, N = 9';
proc print; var mean_mean25 med_mean25 std_mean25 g1_mean25 g2_mean25 min_mean25 max_mean25;
title 'Normal Population, Distribution of Sample Means, N = 25';
**;
proc print; var mean_var9 med_var9 std_var9 g1_var9 g2_var9 min_var9 max_var9;
title 'Normal Population, Distribution of Sample Variances, N = 9';
proc print; var mean_var25 med_var25 std_var25 g1_var25 g2_var25 min_var25 max_var25;
title 'Normal Population, Distribution of Sample Variances, N = 25';
**;
proc print; var mean_std9 med_std9 std_std9 g1_std9 g2_std9 min_std9 max_std9;
title 'Normal Population, Distribution of Sample Standard Deviations, N = 9';
proc print; var mean_std25 med_std25 std_std25 g1_std25 g2_std25 min_std25 max_std25;
title 'Normal Population, Distribution of Sample Standard Deviations, N = 25';
**;
proc print; var mean_Z9 med_Z9 std_Z9 g1_Z9 g2_Z9 min_Z9 max_Z9;
title 'Normal Population, Distribution of Z Test Statistic, N = 9';
proc print; var mean_Z25 med_Z25 std_Z25 g1_Z25 g2_Z25 min_Z25 max_Z25;
title 'Normal Population, Distribution of Z Test Statistic, N = 25';
**;
proc print; var mean_T9 med_T9 std_T9 g1_T9 g2_T9 min_T9 max_T9;
title 'Normal Population, Distribution of T Test Statistic, N = 9';
proc print; var mean_T25 med_T25 std_T25 g1_T25 g2_T25 min_T25 max_T25;
title 'Normal Population, Distribution of T Test Statistic, N = 25';
二维码

扫码加我 拉你入群

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

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

2011-9-18 08:51:37
学习了,谢谢~~~
二维码

扫码加我 拉你入群

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

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

2011-9-18 08:51:47
学习了,谢谢~~~
二维码

扫码加我 拉你入群

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

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

2011-9-21 10:25:11
misslost 发表于 2011-9-18 04:13
options formdlim='-' pageno=min nodate;
DATA normal1; drop obs I;
* randomly sample 2,500,000 scor ...
Thank u  very much!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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