Two-Factor ANOVA Example 1

advertisement
STA 6167, Two-Factor Experiment, Example 1
An engineer is designing a battery for use in a device that will be subjected to some extreme
variations in temperature. The only design parameter that he can select at this point is the plate
material for the battery, and he has three possible choices. When the device is manufactured and
shipped to the field, the engineer has no control over the temperature extremes that the device will
encounter, and he knows from experience that the temperature will probably impact the effective
battery life. However, temperature can be controlled in the product development laboratory for the
purposes of a test.
The engineer decides to test all three plate materials at three temperature levels -- 15F, 70F,
and 125 -- as these temperature levels are consistent with the product end-use environment. Four
batteries are tested at each combination of plate material and temperature, and all 36 tests are run in
random order. (Example from Design and Analysis of Experiments, by D. C. Montgomery).
The SAS program below includes all relevant means, plots, appropriate tests for effects, a
residual plot, and a normal probability plot.
proc format;
value Afmt 1
2
3
value Bfmt 1
2
3
value ABfmt
=
=
=
=
=
=
1
2
3
4
5
6
7
8
9
"1st Material"
"2nd Material"
"3rd Material";
" 15 d F"
" 70 d F"
"125 d F";
= "Type 1, 15 d
= "Type 1, 70 d
= "Type 1, 125 d
= "Type 2, 15 d
= "Type 2, 70 d
= "Type 2, 125 d
= "Type 3, 15 d
= "Type 3, 70 d
= "Type 3, 125 d
;
data one;
input A B y;
label A = "Material Type"
B = "Temperature (degrees F"
y = "Lifetime (hrs.)";
if A = 1 and B = 1 then AB = 1;
else if A = 1 and B = 2 then AB
else if A = 1 and B = 3 then AB
else if A = 2 and B = 1 then AB
else if A = 2 and B = 2 then AB
else if A = 2 and B = 3 then AB
else if A = 3 and B = 1 then AB
else if A = 3 and B = 2 then AB
else AB = 9;
format A Afmt. B Bfmt. AB ABfmt.;
cards;
1 1 130
1 1 74
1 1 155
1 1 180
1 2 34
1 2 80
1 2 40
1 2 75
F"
F"
F"
F"
F"
F"
F"
F"
F";
=
=
=
=
=
=
=
2;
3;
4;
5;
6;
7;
8;
1 3 20
1 3 82
1 3 70
1 3 58
2 1 150
2 1 159
2 1 188
2 1 126
2 2 136
2 2 106
2 2 122
2 2 115
2 3 25
2 3 58
2 3 70
2 3 45
3 1 138
3 1 168
3 1 110
3 1 160
3 2 174
3 2 150
3 2 120
3 2 139
3 3 96
3 3 82
3 3 104
3 3 60
;
proc print;
;
proc sort;by A B;
;
proc means;by A B;
output out=cellmean mean=cm;
var y;
;
proc plot data=cellmean;
plot cm*B=A;
title "Interaction Plot";
;
proc boxplot data=one;
plot y*AB;
title "Side-by-Side Boxplots, Battery Life Experiment";
title2 "for Each Combination of Material and Temperature";
;
proc glm data=one;
class A B;
model y = A|B;
output out=resids r=res;
means A|B;
title "Two-Factor Experiment to Compare Battery Life";
title2 "for Different Materials and Temperatures";
;
proc plot;
plot res*(AB);
;
data two;set resids;
/* The following statement creates a dummy variable with value 1 for every */
/* observation in the data set. This variable will be used to merge the sample */
/* statistics with every observation in the original data set. */
dum = 1;
;
proc sort;by res;
;
proc means;
var res;
output out=meanr mean=mu std=s n=size;
title;
title2;
;
data three;set meanr;dum = 1;
;
data three;merge two three;by dum;
p = (_n_ - 0.5)/size;
/* The following equation would need to be changed for q-q plots for other */
/* probability distributions. For example, for an exponential(mu) distribution,
*/
/* the statement would be Q = -mu*log(1-p). */
Q = probit(p);
;
proc plot;
plot res*AB;
title 'Plot of Residuals vs. Factor Levels';
;
proc reg;
model res = Q;
plot (res predicted.)*Q / overlay;
title 'Normal Probability Plot';
title2 'For Residuals from ANOVA';
;
run;
Download