* Myers and Montgomery, Example 6.2, Table 6.4, p. 234;
data mm_eg62;
input x1 x2 x3 y;
cards;
-1 -1 -1 57
1 -1 -1 40
-1 1 -1 19
1 1 -1 40
-1 -1 1 54
1 -1 1 41
-1 1 1 21
1 1 1 43
0 0 0 63
-2 0 0 28
2 0 0 11
0 -2 0 2
0 2 0 18
0 0 -2 56
0 0 2 46
;
run;
* Create points for contour and 3-d plotting of fitted surface;
data mm_eg62_contour;
do x1=-2 to 2 by .1;
do x2=-2 to 2 by .1;
do x3=-2 to 2 by .1;
* Note, these x values are not exactly increments of 0.1, so round;
x1 = round(x1*100)/100;
x2 = round(x2*100)/100;
x3 = round(x3*100)/100;
output;
end;
end;
end;
run;
data mm_eg62_contour;
set mm_eg62 mm_eg62_contour;
run;
proc rsreg data=mm_eg62_contour out=mm_eg62_out;
model y=x1 x2 x3/nocode actual residual predict;
run;
* Use mm_eg62_out for contour and 3-d plots.;
/*
Can be done in SAS/INSIGHT
Limit which observations
Edit > Observations > Exclude observations, _Type_ ^= PREDICT
Edit > Observations > Hide in graphs, x3 ^= -1
Create plot
Analyze > Contour plot > y in Z, x1 in X, x2 in Y
Change observations to see to get different slices
hide in graph: x3 ^= new value
show in graph: x3 = new value
Alternatively,
Contour, group = x3 will create all the slices
To find the maximum value, can sort predicted values decending
*/
* Or can use gcontour;
* only use predicted values for contour;
data mm_eg62_outc;
set mm_eg62_out;
if _TYPE_ = 'PREDICT';
if x3 = -1; * equilibrium time 10 hours;
run;
* plot contours, corresponds to Fig 6.11(d);
proc gcontour data=mm_eg62_outc;
plot x1*x2=y / GRID AUTOLABEL ; * vert*horz=contour;
run;
quit;