Chapter Contents Previous Next
 General Statistics Examples

## Example 8.7: Response Surface Methodology

A regression model with a complete quadratic set of regressions across several factors can be processed to yield the estimated critical values that may optimize a response. First, the regression is performed for two variables according to the model

y = c + b1 x1 + b2 x2 + a11 x12 + a12 x1 x2 + a22 x22 + e   .
The estimates are then divided into a vector of linear coefficients (estimates) b and a matrix of quadratic coefficients A. The solution for critical values is
x = -(1/2)A-1b   .
The following program creates a module to perform quadratic response surface regression.
```   /*          Quadratic Response Surface Regression            */
/* This matrix routine reads in the factor variables and     */
/* the response, forms the quadratic regression model and    */
/* estimates the parameters, then solves for the optimal     */
/* response, prints the optimal factors and response, and    */
/* then displays the eigenvalues and eigenvectors of the     */
/* matrix of quadratic parameter estimates to determine if   */
/* the solution is a maximum or minimum, or saddlepoint, and */
/* which direction has the steepest and gentlest slopes.     */
/*                                                           */
/* Given that d contains the factor variables,               */
/* and y contains the response.                              */
/*                                                           */
start rsm;
n=nrow(d);
k=ncol(d);                                  /* dimensions */
x=j(n,1,1)||d;                    /* set up design matrix */
do i=1 to k;
do j=1 to i;
x=x||d[,i] #d[,j];
end;
end;
beta=solve(x`*x,x`*y);       /* solve parameter estimates */
print "Parameter Estimates" , beta;
c=beta[1];                          /* intercept estimate */
b=beta[2:(k+1)];                      /* linear estimates */
a=j(k,k,0);
L=k+1;                     /* form quadratics into matrix */
do i=1 to k;
do j=1 to i;
L=L+1;
a[i,j]=beta [L,];
end;
end;
a=(a+a`)*.5;                                /* symmetrize */
xx=-.5*solve(a,b);            /* solve for critical value */
print , "Critical Factor Values" , xx;
/* Compute response at critical value */
yopt=c + b`*xx + xx`*a*xx;
print , "Response at Critical Value" yopt;
call eigen(eval,evec,a);
print , "Eigenvalues and Eigenvectors", eval, evec;
if min(eval)>0 then print , "Solution Was a Minimum";
if max(eval)<0 then print , "Solution Was a Maximum";
finish rsm;
```
Running the module with the following sample data produces the results shown below.

```    /* Sample Problem with Two Factors */
d={-1 -1, -1  0, -1  1,
0 -1,  0  0,  0  1,
1 -1,  1  0,  1  1};
y={ 71.7, 75.2, 76.3, 79.2, 81.5, 80.2, 80.1, 79.1, 75.8};
run rsm;
```

 PARAMETER ESTIMATES BETA 81.222222 1.9666667 0.2166667 -3.933333 -2.225 -1.383333

 CRITICAL FACTOR VALUES XX 0.2949376 -0.158881

 YOPT Response at Critical Value 81.495032

 EIGENVALUES AND EIGENVECTORS EVAL -0.96621 -4.350457

 EVEC -0.351076 0.9363469 0.9363469 0.3510761

 Chapter Contents Previous Next Top