# Example 1: Maximization of a response
# Define a desirability for response y where higher values of y are better
# as long as the response is smaller than high
d = desirability(y, low = 6, high = 18, target = "max")
# Show and plot the desirability function
d
plot(d)
# Example 2: Minimization of a response including a scaling factor
# Define a desirability for response y where lower values of y are better
# as long as the response is higher than low
d = desirability(y, low = 6, high = 18, scale = c(2), target = "min")
# Show and plot the desirability function
d
plot(d)
# Example 3: Specific target of a response is best including a scaling factor
# Define a desirability for response y where desired value is at 8 and
# values lower than 6 as well as values higher than 18 are not acceptable
d = desirability(y, low = 6, high = 18, scale = c(0.5, 2), target = 12)
# Show and plot the desirability function
d
plot(d)
# Example 4:
y1 <- c(102, 120, 117, 198, 103, 132, 132, 139, 102, 154, 96, 163, 116, 153,
133, 133, 140, 142, 145, 142)
y2 <- c(470, 410, 570, 240, 640, 270, 410, 380, 590, 260, 520, 380, 520, 290,
380, 380, 430, 430, 390, 390)
d1 <- desirability(y1, 120, 170, scale = c(1, 1), target = "max")
d3 <- desirability(y2, 400, 600, target = 500)
d1
plot(d1)
d3
plot(d3)
Run the code above in your browser using DataLab