An Introduction to Response Surfaces

Flexibly modeling the relationship between factors and a response.

Kris Sankaran true
10-21-2021

Readings 5.5, Rmarkdown

  1. We’ve really pushed a particular recipe for all our hypothesis testing approaches,

    • Write down a model with various factor level effects
    • Write down a sum-of-squares identity, and get the corresponding degrees-of-freedom
    • Get a test statistic and its reference distribution, for testing each factor We’ve used this in ANOVA, RCBD, general factorial designs…
  2. We’re now going to introduce a quite different approach based on response surfaces. The idea is simple: use a flexible (nonlinear) function from experimental inputs (combinations of factor levels) to the response of interest. This will work as long as the response varies smoothly as factor inputs are perturbed. The estimated function will be a good representation of how varying the factors affects the response.

  3. Moreover, if we have successfully estimated this function, then we’ll be able to use the fit to (a) determine important influences and (b) find configurations that optimize the response (e.g., maximize profit[^Or if you are disgruntled, minimize profit]).

  4. How should we fit these flexible functions?

    • Polynomial regression: include terms like \(x_i^2, x_i^3, x_i^2 x_j, ...\)
    • Spline regression: Include polynomial terms, but split across different regions of the input space. This is generally more stable than polynomial regression.
    • Really, you can use whatever function fitter that you want. Unfortunately, this idea will have to wait till near the end of the course for a more complete elaboration.

Data Example

  1. Let’s look at this idea using the battery data from before. We’ll treat temperature as a continuous variable, so that it makes sense to talk about a response surface[^really, a curve over temperature].
library(dplyr)
library(readr)
battery <- read_table2("https://uwmadison.box.com/shared/static/vmxs2wcsdxkdjujp85nw5kvk83xz4gl9.txt") %>%
  mutate(Material = as.factor(Material))
  1. We fit a quadratic regression to define the surface. The result let’s us make predictions for battery life at temperatures that we haven’t observed. First, we fit a model that uses both Material and a quadratic expansion of Temperature.
fit <- lm(Life ~ Material * poly(Temperature, 2), data = battery)

To visualize the response surface, we compute predictions across a find grid of temperature values for each material.

surface <- expand.grid(
  Temperature = seq(15, 125, by = 1),
  Material = unique(battery$Material) 
  )
surface$Life <- predict(fit, surface)

ggplot(battery, aes(Temperature, Life)) +
  geom_point() +
  geom_line(data = surface) +
  facet_wrap(~ Material)

  1. Compare the associated fit with Table 5.15.
summary(fit)

Call:
lm(formula = Life ~ Material * poly(Temperature, 2), data = battery)

Residuals:
    Min      1Q  Median      3Q     Max 
-60.750 -14.625   1.375  17.937  45.250 

Coefficients:
                                Estimate Std. Error t value Pr(>|t|)
(Intercept)                       83.167      7.501  11.087 1.48e-11
Material2                         25.167     10.608   2.372 0.025059
Material3                         41.917     10.608   3.951 0.000503
poly(Temperature, 2)1           -189.223     45.007  -4.204 0.000257
poly(Temperature, 2)2            109.955     45.007   2.443 0.021385
Material2:poly(Temperature, 2)1  -71.035     63.650  -1.116 0.274242
Material3:poly(Temperature, 2)1   45.928     63.650   0.722 0.476759
Material2:poly(Temperature, 2)2 -158.392     63.650  -2.488 0.019293
Material3:poly(Temperature, 2)2 -197.636     63.650  -3.105 0.004434
                                   
(Intercept)                     ***
Material2                       *  
Material3                       ***
poly(Temperature, 2)1           ***
poly(Temperature, 2)2           *  
Material2:poly(Temperature, 2)1    
Material3:poly(Temperature, 2)1    
Material2:poly(Temperature, 2)2 *  
Material3:poly(Temperature, 2)2 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 25.98 on 27 degrees of freedom
Multiple R-squared:  0.7652,    Adjusted R-squared:  0.6956 
F-statistic:    11 on 8 and 27 DF,  p-value: 9.426e-07