Math 2355

advertisement

Math 2355 – Lab 2

(10pts)

The purpose of Lab 2 is to:

1. Learn more about Excel and how to move around using different sheets.

2.

Apply the method of Least Squares to a set of data using formulas, the Insert Tab and a feature in Excel.

Many applications of mathematics are concerned with the relationship between one quantity x and another quantity y. Often when data is collected and plotted, you will most likely find that the points do not lie on a straight line. However, they will appear to be distributed along a line, in the sense that a line can be drawn to pass very near to all of them. Of all the lines that come close to the points the one that comes closest is called the line of best fit , and the method of least squares, or linear regression, produces its equation.

The method of least squares involves two equations in two unknowns, m (slope) and b (y-intercept). The

Greek letter sigma,

, denotes the “sum.” m

 n

( n

(

 xy )

( x 2

)

  

 

2

) y b

 y

 m n

  x

Where

n = the number of points

 x = the sum of the x values

 y = the sum of the y values

( x

2

) = the sum of the squares x 2

( xy ) = the sum of the products xy

After finding the above values, you find m (using the first equation) and then find b, by plugging the exact value of m found in the first equation, using the second equation. Upon solving for m and b you can then write the equation for the line of best-fit, y=mx+b .

Consider the following problem:

Ms. Nugent is head of advertising sales at a TV station. As part of her sales pitch to other car dealers, she has collected the following data relating advertising spots per week and the number of sales Car Mart made during the week. She wishes to use this information to formulate an equation that she will use to determine the number of car sales that could be expected if the ad were run a certain number of times per week.

The following information was collected:

Number of ads run in a week, x: 5 15 12 20 0 9 18

19 32 10 18 25

PART 1:

Number of cars sold that week, y: 15 20

Using EXCEL, enter the x-data in column A and the y-data in column B:

A B

1 5 15

2 15 20

3 12 19

4 20 32

5 0 10

6 9 18

7 18 25

2

Plot the data using an Insert Scatter Plot or Bubble Chart (a graph that plots only the points). To do this, highlight the data in A1 through B7.

- Click on the Insert Tab and then in the Charts group click on the chart button in the bottom row on the right ( Insert Scatter Plot or Bubble Chart button). It looks like a bunch of plotted points on a graph.

- From the Scatter group choose the upper left hand option that is simply plotted points.

- Your data should now display as shown below.

- You now need to format the chart.

-Click on the graph to highlight it. You should now see three icons on the upper right side. Click on the icon with the + sign and you should see a box labeled Chart Elements . Check mark, if it’s not already done, Axes, Axis titles, Chart title and Gridlines. You should now have labels on the chart for Chart Title and Axis Titles. Double click on Chart Title, highlight the words and type in the new title, Ads Run vs.

Cars Sold . In the same fashion change the x-axis title to Ads Run per Week and the y-axis title to Cars

Sold per Week . You’ll notice when you go to edit one of this boxes that a format menu appears. For now we’ll not worry about formatting these frames.

Note: the Chart Tools tab will not display unless the chart has been, or stays, selected.

- Your chart should now appears as follows. Note: the chart can be expanded by positioning and dragging the mouse on the dotted edges along the borders of the chart while the chart is in edit mode.

3

Using the Chart Tools Format or the Home tab you can also change the x-scale, the y-scale, the size of the font, the font itself or the titles, to name a few. To do these you click once on the object to highlight the box. Then choose the new format for the box. To change a label, click once to activate the text box and then click again to put it into edit mode so you can type or delete.

Note that the chart above would certainly indicate a relationship between ads run and cars sold, so now you will use Excel to find the Least Squares Line (the line of best fit).

PART 2

The line of best fit is calculated by finding m & b associated with the 2 equations given on page 1.

To do this you need to find (

 x), (

 y), (

 x 2 ), and (

 xy), which is a simple matter for Excel.

(Note that n is just the number of points, or 7, for this problem).

You will need to use columns C and D. Since the chart is in the way, you need to move it. It’s easy! Move the mouse cursor onto the chart and click once (do not click on the graph portion). The chart is put in edit mode (dots appear at the corners and middles of each border). While holding the left mouse button down, simply drag the chart to C10; that is, the upper, left corner of the chart is placed in C10, and it’s redrawn there. You’re done.

In C1, enter the formula =A1*A1 The = sign tells Excel that your are entering a formula.

( Or you can enter the formula =A1^2 ) which is equivalent to x 2

In D1, enter the formula =A1*B1 which is equivalent to xy

Now highlight C1 AND D1, then position the mouse cursor on the fill handle in the lower right corner of

D1, drag down through D7(the cross becomes solid). This will copy the formulas from C2 through D7 relative to the formulas entered in C1 and D1.

You will now produce the sums (

 x), (

 y), (

 x 2 ), and (

 xy), in Row 8 (A8 through D8):

- Click on A8, then enter the formula =Sum(A1:A7)

- Use the fill handle on A8 to drag the formula through D8 copying the sum formula for each column that you drag through.

You should now be observing the following table of values:

A B

1 5 15

C

25

D

75

2 15 20

3 12 19

4 20 32

5 0 10

225

144

400

0

300

228

640

0

6 9 18

7 18 25

81

324

162

450

8 79 139 1199 1855

The entries in A8 through D8 correspond to (

 x) = 79, (

 y) = 139, (

 x 2 ) = 1199, and (

 xy) = 1855.

4

Using the above sums, the least square equations are: m

7

(

7

1855

1199

79

79

139

2

) and b

139

7 m

79

If you wish you can now solve for m and then for b, using the value you found for m, by “hand” (preferably with a calculator). You should use the exact value of m when finding b, after which you may round both values according to what you are asked for.

The solution, using four-decimal accuracy, is m =0.9312 and b =9.3476. Since the line of best fit is given by y = mx + b you can now write that the line of best fit for this data (to 3-decimal places) is y = 0.9312

x + 9.3476

PART 3:

That is, (Cars sold per week) = 0.9312(Ads run per week) + 9.3476

The equation you have derived may be used to study other scenarios. For example, a business placing 50 ads per week, should expect:

(Cars sold per week) = 0.9312(50) + 9.3476 = 55.9076, so approximately 56 cars sold per week when 50 ads are run per week.

We can now calculate Ads Run values based on the Least Squares Equation, y = 0.9312

x + 9.3476, for each value of x.

- First copy the x-values (A1 through A7) to a different location, say F1:F7 by:

- Highlight cells A1:A7

- Right mouse button click and choose Copy or use the keyboard shortcut, Ctrl+C.

- Then click on F1 and hit Enter .

- Next click on G1 and enter the formula = 0.9312*F1 + 9.3476

(the least squares equation)

- Copy the formula from G2 through G7 using the fill handle on the lover right corner of G1 (place the mouse on the lower right corner of G1 and drag it through G7).

PART 4:

Finally, now that you have done all this work, we will look at the easy way to perform linear regression analysis.

- Activate the chart, by clicking on it. Click on the icon with the + sign and you should see a box labeled

Chart Elements , go to Trendline , click on the dropdown arrow and choose More Options… (as shown below).

From the Format Trendline box choose Display Equation on chart.

Notice that this is where you have options for other types of trendlines. For this example we want Linear . You should now see the line and its equation displayed on the graph. Close the Format Trendline box.

You may need to move and/or format the equation so it is easier to read.

The following chart is observed:

5

Rename this sheet as: L2 Ex. Go to the next sheet, or if necessary, insert a new sheet.

Think about what you have learned. There is usually more than one way to get to the answer.

Math 2355 – Lab 2 – Spring 2016 (10pts)

Name: ______________________________________ Discussion Section: ____________

Due Date: February 12 th , by 8:30am

Not all data lends itself to a line of best fit. In this problem you will determine the parabola of best fit ( y=ax 2 +bx+c ). If you were to do it by hand, you would solve the following system of equations for a, b , and c .

 x

2 y

(

 x

4

) a

(

 x

3

) b

(

 x

2

) c

 xy

(

 x

3

) a

(

 x

2

) b

(

 x ) c

 y

(

 x

2

) a

(

 x ) b

 n c

Add a new sheet to your Excel file after L2 Ex, rename it L2, and use it to do the following problem:

A company decides to develop a cost equation based on the quantity of the product produced in a day. The quantity, x, has domain [0,

200].

They collected the following data:

Quantity produced

Cost (in dollars)

20

642.35

35

766.48

50

858.82

65

928.83

80

1005.32

95

1078.82

110

1140.79

Using Excel create two columns, one labeled Quantity produced and the other labeled Cost in dollars and enter the associated values.

Create a scatter plot of the data and add a parabola of best fit (see part 4 of the lab, this is done using the Format Trendline box).

Hint: When you add the “trendline”, for it to be a parabola you need to choose Polynomial of order 2 . Also, be sure to select Display

Equation on chart.

Format the equation of best fit so it is font size 12. To do this right mouse button click on the equation and choose Font .

Label the chart and the axis appropriately (you may have to add axis titles by using the + symbol). All should be font size 12.

Format the axis values so the font size is 9.

The chart should be enlarged to a reasonable size so that all numbers can be easily read.

Type your name in C1.

Select a print area and print, in landscape form, the worksheet with its data and chart.

Attach the page you print to the back of this page as it is worth points.

(a) What is the equation of the parabola of best fit?

(b) According to the parabola of best fit, what total daily cost might they expect if the company increases production per day to

150 units?

(c) If this trend continues, approximately how many units will they produce in a day when costs are $1287? Show your work.

Give your answer to the nearest unit.

Do not turn in the entire lab. I only want this page, along with the print out I ask for on this page. You should only have 2 pages to turn in for this lab. This should be the cover page.

Download