楼主: winddr
20311 189

bayesian analyses using sas course note 免费   [推广有奖]

171
chiaolee 发表于 2013-7-8 18:23:25
take a look
患難生忍耐,忍耐生老練,老練生盼望;盼望不至於羞恥

172
ernestdwu 发表于 2013-7-10 00:31:12
NICE!!!!

173
yuerqieqie 发表于 2013-7-10 20:59:37
看看

174
zxx38 发表于 2013-8-15 10:33:15
谢谢分享

175
timing 发表于 2013-8-22 23:47:12

%let n1 = 10;           /* group sizes*/
%let n2 = 10;
%let NumSamples = 5000; /* number of simulated samples */  

data PowerSim(drop=i);
call streaminit(321);
do Delta = 0 to 2 by 0.1;
   do SampleID = 1 to &NumSamples;
      c = 1;                            /* Group 1 */
      do i = 1 to &n1;
         x = rand("Normal", 0, 1);      /* x ~ N(0,1) */
         output;
      end;
      c = 2;                            /* Group 2 */
      do i = 1 to &n2;
         x = rand("Normal", Delta, 1); /* x ~ N(Delta, 1) */
         output;
      end;
   end;
end;
run;

/* 2. Compute (pooled) t test for each sample */
%ODSOff
proc ttest data=PowerSim;
   by Delta SampleID;
   class c;
   var x;
   ods output ttests=TTests(where=(method="Pooled"));
run;
%ODSOn

/* Construct indicator var for obs that reject H0 at 0.05 significance */
data Results;
   set TTests;
   RejectH0 = (Probt <= 0.05);
run;

/* 3. Compute proportion: (# that reject H0)/NumSamples and CI */
%ODSoff
proc freq data=Results;
   by Delta;
   tables RejectH0 / nocum binomial(level='1');
   output out=Est binomial;
run;
%ODSOn

/* for comparison, compute exact power */
proc power;
  twosamplemeans  power = .           /* missing ==> "compute this" */
    meandiff= 0 to 2 by 0.1           /* delta = 0, 0.1, ..., 2     */
    stddev=1                          /* N(delta, 1)                */
    ntotal=20;                        /* 20 obs in the two samples  */
  ods output Output=Power;            /* output results to data set */
run;

data Combine;
   set Est Power;
run;

/* overlay the simulated results with the cuve of exact power */
title "Power of the t Test";
title2 "Samples are N(0,1) and N(delta,1), n1=n2=10";
proc sgplot data=Combine noautolegend;
   series x=MeanDiff y=Power;
   scatter x=Delta y=_BIN_ / yerrorlower=L_Bin yerrorupper=U_Bin;
   inset ("Number of Samples"="&NumSamples") / border;
   yaxis min=0 max=1 label="Power (1 - P[Type II Error])" grid;
   xaxis label="Difference in Population Means" grid;
run;

176
sharpyaoyun 发表于 2013-8-30 20:54:44

177
davidzeng 发表于 2013-9-11 22:46:58
学习学习

178
xiaohei929 发表于 2013-9-12 22:01:45
kankan

179
fufusix 发表于 2013-9-12 22:18:00
Kan Kan

180
ynaktank 发表于 2013-9-13 22:43:52
好书,目前急需,是否可以赠送

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

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