I'm creating a factorial design experiment with 8 predictor variables. I'm using the %mkt function to create a randomised design, however, I need the 8th variable (in pink, which equates true or false news) to be balanced. Specifically, for each block (survey) I need to make sure theres 4x level 1 (true news) and 4x level 2 (fake news). I think I might need to use the balance function, but I don't know how to specify it to a specific variable.
%mktruns (3 2 2 2 3 3 2 2)
%mktex (3 2 2 2 3 3 2 2, interact=@2, n=96, seed = 12345)
%mktblock (nblocks = 12)
See
SAS Macros for Experimental Design and Choice Modeling
And maybe @WarrenKuhfeld reads along.
Ciao,
Koen
There are multiple ways to approach this. It occurred to me that the easiest way might be to build the Block and x8 relationship as the initial design then fill in the rest of the design around it.
%mktex(12 2, n=96) data init; set design; retain x2-x9 .; x9 = x2; x2 = .; run; proc print; run; %mktex(12 3 2 2 2 3 3 2 2, n=96, init=init, interact=x2|x3|x4|x5|x6|x7|x8|x9@2, seed=12345) %mktlab(data=design, vars=Block x1-x8) proc sort; by block x8; run; proc print; id block; by block; run; proc freq; tables block * x8; run;
Thanks so much for your help @WarrenKuhfeld! The code works and creates the design I need, but the d-efficiency comes out lower (84.46) in this code than when I ran my original code (around 94ish). Additionally, when I change the number of blocks in your code to try and increase the d-efficiency, it always comes out high (around 99). This is the case for all other numbers of blocks (I've tried 11, 13, and 14) apart from 12.. I'm not sure if I've done something wrong but I've included the code below for when I did 11 blocks:
%mktex(11 2, n=99)
data init;
set design;
retain x2-x9 .;
x9 = x2;
x2 = .;
run;
proc print; run;
%mktex(11 3 2 2 2 3 3 2 2, n=99, init=init,
interact=x2|x3|x4|x5|x6|x7|x8|x9@2, seed=12345)
%mktlab(data=design, vars=Block x1-x8)
proc sort; by block x8; run;
proc print; id block; by block; run;
proc freq;
tables block * x8;
run;
You are welcome.
You are comparing apples and oranges. If you want to compare the efficiency to the design you originally found (which does not conform to your desired restrictions) then you must evaluate the D-efficiency without the Block variable. This step will do that:
%mktex(3 2 2 2 3 3 2 2, n=96, init=final(drop=block),
options=check, interact=@2, seed=12345)
When you impose restrictions, then you typically will get a lower D-efficiency.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.