/* new simulation double the smaple size, i.e., use 12 cages */ option ls=76 nocenter; %let seed = 71853048; %let var_cage = 5.03; %let var_cc = -6.24; %let var_resid = 31.56; %let nsim = 1000; %let condm1 = 56; %let condm2 = 53; /* Input the condition means */ %let condm3 = 59; %let condm4 = 60; proc iml; cov = &var_cc * j(3,3) + &var_resid * i(3); covh = half(cov)`; print cov covh; run; data noise; retain i j; do sim = 1 to ≁ i = 1; j = 2; do cage = 1 to 12; /* cage =12 to double the sample size */ u_cage = sqrt(&var_cage) * rannor(&seed); do condition = i,j; e1 = rannor(&seed); e2 = rannor(&seed); e3 = rannor(&seed); diet = "normal "; noise = u_cage + 5.0318983*e1; output; diet = "restrict"; noise = u_cage - 1.240089*e1 + 4.8766977*e2; output; diet = "suppleme"; noise = u_cage - 1.240089*e1 - 1.594895*e2 + 4.6085237*e3; output; end; j = j + 1; if (j = 5) then do; i = i + 1; j = i + 1; end; if(cage=6) then do;i=1;j=2; end; /* new line added */ end; end; run; DATA non_null;SET noise; /* Create non_null data */ y=noise; IF condition=1 THEN y=y+&condm1; IF condition=2 THEN y=y+&condm2; IF condition=3 THEN y=y+&condm3; IF condition=4 THEN y=y+&condm4; ods exclude all; /* These two ods statements are for the next proc mixed */ ods noresults; proc mixed data=non_null nobound; /* Note: DATA=non_null */ by sim; class cage condition diet; model y=condition|diet; random cage cage*condition; /*parms &var_cage &var_cc &var_resid; */ /* These parms will help the iteration process in computation */ /* It is unnecessary. See output12_6b.sas */ ods output covparms=cpsim tests3=t3sim; run; ods exclude none; ods results; proc sort data=cpsim; by covparm; run; proc means data=cpsim; /* output the mean variance components */ by covparm; var estimate; TITLE 'Output the variance components'; /* added statement */ run; data t3sim; set t3sim; if probf < 0.05 then sig = 1; else sig = 0; proc sort data=t3sim; by effect; proc means data=t3sim mean; by effect; var sig; TITLE 'Output the number of rejection under the null'; /*added statement */ run; PROC PRINT DATA=non_null (obs=10);VAR cage condition diet noise y;