****************
* redwing3.sas *
****************;
* This program is part of lab 9 for STAT 8200, Fall, 2013;
options nodate pageno=1 ;
ods graphics off; * Not going to use ODS graphics in this example;
ods listing gpath="c:\temp";
ods pdf file="mypath\redwing3.pdf"; * change mypath to a path on your USB drive;
data redwing2;
input treat $ block oil;
cards;
a 1 34.4
a 2 35.9
a 3 36.0
a 4 34.1
b 1 33.3
b 2 31.9
b 3 34.9
b 4 37.1
c 1 34.4
c 2 34.0
c 3 34.5
c 4 33.1
d 1 36.8
d 2 36.6
d 3 37.0
d 4 36.4
e 1 36.3
e 2 34.9
e 3 35.9
e 4 37.1
f 1 36.4
f 2 37.3
f 3 37.7
f 4 36.7
a 1 36.2
a 2 35.9
a 3 37.8
a 4 36
b 1 33
b 2 30.8
b 3 34.3
b 4 36.7
c 1 34.5
c 2 34.5
c 3 34.1
c 4 32.2
d 1 36.1
d 2 35.6
d 3 38.5
d 4 36.1
e 1 37.4
e 2 33.8
e 3 36
e 4 35.6
f 1 37.4
f 2 37.3
f 3 37.2
f 4 36.4
;
run;
proc sort data=redwing2;
by block treat;
run;
proc means data=redwing2 noprint;
by block treat;
output out=eudata mean=eumean;
run;
title 'Means over the 2 sub-samples for each experimental unit';
proc print data=eudata;
run;
title "Method 1 Analysis: Analyze Plot Means (exp'tal unit-level data)";
title2 'Here block effects are treated as random';
proc mixed data=eudata method=type3;
class block treat;
model eumean=treat;
random block;
contrast 'no inoc vs inoc' treat -1 -1 -1 -1 -1 5 ;
run;
title 'Method 2 Analysis: Analyze Sub-sample Data (pseudo-rep-level data)';
title2 'Here block effects are treated as random';
proc mixed data=redwing2 method=type3;
class block treat;
model oil= treat;
random block block*treat;
contrast 'no inoc vs inoc' treat -1 -1 -1 -1 -1 5 ;
run;
* Note that above, PROC MIXED automatically used the right denominator
(MS_block*treat) for the F test for treat. If PROC GLM is used to do the analysis,
it will not use the correct denominator for this test unless explicitly
told to do so. This can be done as follows:
;
title 'Method 2 Analysis: Analyze Sub-sample Data (pseudo-rep-level data)';
title2 'Here block effects are treated as fixed';
title3 'and the analysis is done in PROC GLM';
proc glm data=redwing2;
class block treat;
model oil=block treat block*treat;
test h=treat e=block*treat;
/* Note that the above test can be obtained in a more automatic way by
specifying block and block*treat on the RANDOM statement and including the
option /TEST. This will produce the correct anova table, labelled in the output:
Tests of Hypotheses for Mixed Model Analysis of Variance. I've included
the appropriate specification of the RANDOM statement below (commented
out with a *). Try it! (Remove the * in the statement below, comment out the
TEST statement above and then rerun the program).*/
*random block block*treat / test;
contrast 'no inoc vs inoc' treat -1 -1 -1 -1 -1 5 / e=block*treat;
run;
* Note also that neither block nor block*treat should be tested in this
design;
ods pdf close;