Goal_Seek__Solver_and_Regression
Goal_Seek__Solver_and_Regression
Introduction
You can use Excel to solve optimization problems or mathematical problems.
For simple problems, Goal Seek is used, while Solver is used for more complex problems.
Goal Seek
In the formula y = x² - 2x - 3 above, the solutions to that formula when y=0 are x = 3 and x =
-1.
We could also have found these values without entering the data, calculating the formula or
plotting the graph by using Goal Seek.
12. Click in cell B14 and type =A14*A14-2*A14-3, then hit [Ctrl-Enter].
13. Click on the Data tab and, in the Forecast area, use the pulldown on the [What-If
Analysis] and choose [Goal Seek...].
14. In the Goal Seek dialog box, leave the Set cell option at B14, type 0 in the To value and
type A14 in the By changing cell box.
Goal seek calculates and enters the value -0.99992 into cell A14. Goal Seek has pre-set limits
within it, and when it finds a value within these limits, it stops.
16. Click [OK] to accept the Goal Seek solution.
The pre-set limits can be changed in the Excel Options area, and changing the options can
increase the accuracy of the Goal Seek output.
24. Copy the formula in cell B14 and paste it in cell B15.
25. Run Goal Seek again, this time using the values of B15, 4 and A15.
26. Click [OK].
27. At y = 4, what is x?
Solver
We’ve used Goal Seek with two cells – a target and a changing cell. When we want to solve
problems using multiple cells (storing and/or calculating values), we need to use Solver.
Within the Solver functionality, you also have the ability to set up constraint criteria in cells.
28. If you do not already have the Developer tab, click on the File tab, then click Options.
On the left, click on Customize Ribbon and on the right click in the checkbox next to
Developer.
29. Click on the Developer tab and from the Add-Ins area click on Excel Add-Ins (the
middle option – don’t click the first Add-ins button!)
30. Check the boxes for Analysis Toolpak and Solver Add-In.
31. Click [OK].
32. Click on the Data tab and a new area has appeared – the Analysis area is the last area
on the right side of the Ribbon.
33. Copy the formula from cell B15 and paste it into cell B16.
34. From the Data tab, in that new Analysis area, click on [Solver].
The Solver Parameters dialog box opens.
35. If it is not already in the Set Objective box, type $B$16 in the box.
36. Click the circle next to Value of: and leave the value set to 0.
37. In the box below By Changing Variable Cells: type A16.
38. Click on [Solve].
The Solver Results dialog box opens once Solver finds a solution.
39. Click [OK] to accept the solution.
40. My solution was 3. Does yours match?
41. Copy the formula from cell B16 and paste it in cell B18.
42. Click on Solver again.
43. Change the Set Objective to cell B18 (still using absolute values)
44. Change the By Changing Variable Cells to A18 (also still using absolute values.
45. Uncheck the box next to Make Unconstrained Variables Non-Negative.
46. Click the Add button to the right of the large Subject to Constraints box.
47. Type A18 in the Cell Reference box, leave <= in the center area, and type 0 in the
Constraint box.
48. Click [OK]. You’ll see that the large center box now contains your constraint:
51. Copy the formula from cell B18 and paste it in cell B20.
52. From the Data tab, click on [Solver].
53. Highlight the formula in the Subject to the Constraints area by clicking on it, and click
the [Delete] button.
54. Change the A and B formulas in the Set Objective and By Changing Variable Cells
options to match the new cells (A20 and B20).
55. Change the To: area from Value to Min.
56. Click [Solve] and then accept the Solver solution. Your sheet at this point should look
like this:
Now we need to set up a constraint that mandates that the y and z values should be equal.
62. On the Data tab, click on [Solver] and check that To: is set to Max
63. The Set Objective cell should be C14, and the Changing Variable Cells should be set to
A14.
64. Click on the [Add] button and set a constraint of B14 = C14 (make sure to change
the center section this time).
65. Click [OK]
66. Click [Solve] and accept the Solver solution.
If we had performed this same operation using Min instead of Max, we would have gotten the
same result. This is because in actuality, there are two values of A14.
67. Copy the formula in cell C14 and paste it into C15.
69. The Set Objective cell should be C15 and the Changing Variable Cells should be set to
A15.
71. Click [Add] to add a second constraint. Type A15>=0 (again you’ll have to change
the center section).
72. Click [Solve] and accept the Solver solution. It should match your solution in row 14!
73. Type 10 into cell A15. This should change your y and z values.
Further Examples
The examples so far have been very scientific and based on a single cell.
Now let’s look at non-scientific problems using multiple cells.
Buying Chocolate
You have $2.00 to spend on chocolate. A small chocolate bar costs 17 cents, a large bar costs
32 cents. The small bars are on special – if you buy 3, you get one free.
If you want to spend your entire $2.00 on chocolate, how many of each bar should you buy?
74. Click the plus sign next to Sheet1 to add a new worksheet.
75. Click in cell A2 and type ‘Large’.
76. Click in cell A3 and type ‘Small’.
77. Click in cell A4 and type ‘Special’.
78. Click in cell A5 and type ‘Total Small’.
79. In cell B1 type ‘Number’.
80. In cell C1 type ‘Cost’.
81. Click in cell B2 and type 1.
82. In cell C2 type ‘=B2*.32’
83. In cell B3 type 1, and in C3 type ‘=B3*.17
84. In cell B4 type 1, and in C4 type ‘=B4*(.17*3)
85. In cell B5 type =B3+4*B4.
86. In cell C5 click on the [AutoSum] button and accept the formula when it totals C2 –
C4.
87. Finally, in cell A7 type Budget and in B7 the value 2.00. You should have a table of
information all set up for Solver, like so:
92. Click the plus sign to add a new worksheet and type in the above table (using cells A1
to G5). This is required because there is already Solver in use on the other tabs – you cannot
put multiple Solver solutions on one worksheet page.
93. Click in cell I1 and type Stocks.
94. Fill cells I2 to I5 with the current stock levels - 180 , 200 , 300 and 220
95. Click in cell A7 and type Orders
96. In cells B7 to G7 type the order numbers - 100 , 200 , 150 , 100 , 180 and 120
97. Select cells A2 to A5 and [Copy] them.
98. Click in cell A9 and press [Enter] to paste the copied cells.
99. Click in cell I9 and type the formula =SUM(B9:G9).
100. Copy this formula down to cell I12
101. Click in cell A14 and type Totals
102. In cell B14 type the formula =SUM(B9:B12)
103. Copy this formula across to cell G14
104. Click in cell A16 and type Costs
105. In cell B16 type the formula =B2*B9+B3*B10+B4*B11+B5*B12
106. Copy this formula across to cell G16
107. Click in cell I16 and type =SUM(B16:G16).
Your data is now set up for Solver:
You need to minimize the total costs (stored in I16) by changing the values in B9 to G12,
subject to various constraints.
108. From the Data tab, click on [Solver]
109. Make the Set Objective: as I16 then To: to Min and By Changing Variable Cells: to
B9:G12
110. Click on [Add] to put in the following constraints:
a. B9:G12 >= 0 (you can't have negative orders)
b. B9:G12 int (the orders must be whole numbers)
c. I9:I12 <= I2:I5 (the orders must be within stock limits)
d. B7:G7 = B14:G14 (the totals must equal the orders)
Your Solver should look like this:
Regression
Regression is a statistical measure used mostly in Accounting and Finance the determines the
relationship between one dependent variable and a series of other, changing independent
variables that you suggest may have an impact on the dependent variable (usually denoted as
“y”). Regression analysis determines which of those changing variables, or factors, do have a
direct impact.
Suppose you are a Sales Director, and you are trying to determine if the current marketing
campaigns for each of the products your company sells is successful, or if the marketing budget
assigned to those products needs to be adjusted. So you want to determine if there is a relation
between how many of each product you sold and the marketing budget (along with the price of
the product). In other words, can you predict how many products you will sell based on the
products price and marketing budget?
113. In your workbook, click the plus sign next to Sheet3 to add another worksheet.
114. In cell A1, type ‘Sales Quantity’.
115. In cell B1, type ‘Item Price’.
116. In cell C1, type ‘Marketing Budget’.
117. Resize your columns so everything fits nicely.
118. Enter the following data so your Excel table looks like this:
Sales Item Marketing
Quantity Price Budget
8500 $2 $2,800
4700 $5 $200
5800 $3 $400
7400 $2 $500
6200 $5 $3,200
7300 $3 $1,800
5600 $4 $900
121. In the list, find and Highlight Regression and click [OK].
122. The Regression toolbox window opens.
123. Set the Input Y Range to $A$1:$A$8 (this is your dependent, or predictor,
variable)
124. Set the Input X Range to $B$1:$C$8 (these are your independent, or
explanatory, variables). Note** For Excel regression to work, these columns
MUST be adjacent to each other.
125. Check the box next to the Labels option.
126. Make your Output Range $A$11.
127. Check the box next to the Residuals option.
128. Your Regression box should look like this one:
SUMMARY OUTPUT
Regression Statistics
Multiple R 0.9806814
R Square 0.9617361
Adjusted R Square 0.9426041
Standard Error 310.52392
Observations 7
R Square
The R Square figure is a measure, statistically, of how close your data is to the regression line.
It is also called the coefficient of determination. So, how good is your model data? With an R
Square of 0.9617361, this means that 96% of the variation of Sales Quantity can be explained
by the independent variables Item Price and Marketing Budget. The closer the R Square is to 1,
the better the regression fits the data.
Significance Values
To measure the statistical significance of your regression results, you want to look at the
Significance F value and your P values (shaded in green below):
If your Significance F value is below 0.05, your regression is okay. Higher than 0.05, and you
need to select a new set of independent variables. Check the P-values – any variable with a P-
value higher than 0.05 needs to be deleted. Then rerun regression without that variable (or add
a different variable) to see how your Significance F changes. Hopefully, it drops below 0.05. In
the regression for this assignment, all P-values are below 0.05.
ANOVA
df SS MS F Significance F
Regression 2 9694299.568 4847150 50.26854 0.001464128
Residual 4 385700.4318 96425.11
Total 6 10080000
Standard
Coefficients Error t Stat P-value Lower 95% Upper 95% Lower 95.0%
Intercept 8536.2139 386.9117478 22.06243 0.000024 7461.974654 9610.453111 7461.974654
-
Item Price -835.7224 99.65304469 -8.38632 0.001106 -1112.40356 559.0411432 -1112.40356
Marketing
Budget 0.5922285 0.104346803 5.675579 0.004755 0.302515325 0.881941666 0.302515325
Coefficients
The regression line is calculated using the coefficients (shaded in blue above). The regression
line is equal to y = Sales Quantity = 8536.2139 -835.7224*Item Price +0.592285*Marketing
Budget]. In other words, for each unit that the Item Price increases, the Sales Quantity
decreases by 835.7224 items. And for each unit increase in the Marketing Budget, the Sales
Quantity increases by 0.592 items. This is very valuable information to the Sales and Marketing
departments. These coefficients are also useful to do forecasting. If the Item Price is $4 and the
Marketing Budget is $3000, you can plug those numbers in to forecast the Sales Quantity –
8536.214-835.722*4+0.592*3000=6970.
130. In your worksheet, on Sheet4 in cell E1, calculate what your Sales Quantity would be
if the Item Price was $3.50 and the Marketing Budget was $3800. Round it to whole
units.
Residuals
We included residuals in our regression analysis. These numbers show you how far away your
actual data points are from the predicted data points. It takes the value found in the regression
equation, and adds or subtracts it from the Sales Quantity indicated in column A. So for
Observation 1, the predicted Sales Quantity was 8536.214-835722*2+0.592*2800 = 8523,
while the actual Sales Quantity was 8500, so the residual is 8500-8523 = -23 (or -23.00896712)
131. Create a scatter plot chart (just a regular scatter, no smoothing or lines) of just the
residual numbers in your worksheet. Change the Chart Title to Residuals.
132. Move the chart so that the upper left corner aligns with cell E3.
Click on the File tab, save the file to your computer, then answer the goal seek assessment
based on your file and/or comprehension of the lecture.