0% found this document useful (0 votes)
29 views15 pages

Goal_Seek__Solver_and_Regression

Uploaded by

olansatura658
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views15 pages

Goal_Seek__Solver_and_Regression

Uploaded by

olansatura658
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

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.

1. Open a new, blank Excel worksheet.


2. Click in cell A1 and type x.
3. Click in cell B1 and type y.
4. Click in cell A2 and type -5.
5. Click in cell A3 and type -4.
6. Highlight both A2 and A3.
7. Click and drag the black plus sign (the range handle) from the bottom of cell A3 down
through cell A12.
8. Click in cell B2 and type the formula to find slope =A2*A2-2*A2-3. This formula is
equivalent to y = x² - 2x – 3.
9. Drag down from B2 through B12 to copy the formula to the open B cells.

Now plot the data on a graph:

10. Highlight all the data (cells A2 through B12).


11. From the Insert tab, in the Charts area, click on the pulldown for the Insert Scatter
(X,Y) or Bubble chart and select the Scatter with Smooth Lines and Markers chart
option (it’s the middle top one under Scatter).

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.

15. Click [OK].

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.

17. From the File tab, click on Options.


18. On the left side, click on Formulas.
19. In the Calculation Options area, add two zeros to the Maximum Change value after the
decimal, making it 0.00001.
20. Click [OK].
21. Rerun the Goal Seek with the same values as before. Does the value in cell A14 change
to a more accurate value?
22. Because there was no data in cell A14 when you first ran Goal Seek, the pre-set
algorithm calculated the closest root value to the beginning value (which was 0 since
there was no data in A14).
23. Click in cell A14 and type 6.
24. Rerun the Goal Seek again using the same values as before. (B14, 0, A14).
Again, having used the formula y = x² - 2x - 3 above, the solutions to that formula when y=0
are x = 3 and x = -1. So the root results Goal Seek is targeting are 3 and -1. What results did
you get now? I got 3.
If you want to find the x value for a different y value (other than 0), type the value you want to
use in the To value: area when setting the Goal Seek.

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.

Before you can use Solver, you have to install it.

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!)

The Add-Ins box appears.

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:

49. Click [Solve].


50. Click [OK] to accept the Solver solution of -1.
Solver can also be used to find the Minimum or Maximum value. This makes Solver useful for
Accounting uses, not just Mathematics.

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:

Solving Two Equations


We can also use Solver to find where two graphs cross.

55. Click in cell C1 and type the letter z.


56. Press [Enter].
57. In cell C2 type the formula =8+2.5*A2-0.5*A2*A2
58. Copy the formula down to fill in the open column C cells down through cell C12.
59. Highlight cells C1:C12 and [Copy]
60. Now right click on the graph and choose [Paste] to add a new line to the graph.
61. Click in cell C12, copy the formula and paste it into cell C14.

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.

68. Click on [Solver]

69. The Set Objective cell should be C15 and the Changing Variable Cells should be set to
A15.

70. Change the existing constraint to read B15 = C15.

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:

88. Move to the Data tab and click on [Solver]


89. Set the Set Objective: to C5, To: to Max and By Changing Variable Cells: to B2:B4
90. Next, add the following constraints (note that you can use ranges to define them):
a. C5 = B7 (total cost must equal the budget)
b. B2:B4 >= 0 (you can't have negative numbers)
c. B2:B4 int (this sets the constraint values to integer – done because you can't
cut a chocolate bar into pieces)
91. Click [Solve] and keep the Solver Solution. You should buy 2 large, 2 small and 2
special with your $2.00 budget to get your maximum chocolate value!
Supplying Shops
A wholesaler has 4 depots supplying shops around Arizona. It receives orders from stores in
Phoenix, Mesa, Flagstaff, Chandler, Tucson and Scottsdale for the following quantities of its
products: 100, 200, 150, 100, 180 and 120. Stocks in the depots (in Tempe, Ahwatukee, Peoria
and Glendale) stand at 180, 200, 300 and 220. Which depot should supply how much to what
stores given the relative costs (transport etc.) shown in the table below?

Phoenix Mesa Flagstaff Chandler Tucson Scottsdale


Tempe 12 7 8 7 10 9
Ahwatukee 15 10 11 4 8 13
Peoria 5 9 11 13 14 6
Glendale 4 7 8 14 15 6

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:

111. Press [Solve] and then keep the Solver Solution


112. The minimum costs should be 5880.

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

119. On the Data tab, click the Data Analysis button.


120. The Data Analysis tool window opens:

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:

129. Click [OK]


Excel produces a Summary Output, rounded to three decimal places.
So what does it mean?

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.

You might also like