You are on page 1of 23

THE UNIVERSITY OF NEW SOUTH WALES School of Economics ECON1203/ECON2292 Business and Economic Statistics Session 2, 2011

Computing Work Document

Table of Contents
Introduction .................................................................................................................................... 2 Getting started in the University Labs ......................................................................................... 3 Becoming familiar with the Excel Worksheet ............................................................................. 3 Data files .................................................................................................................................... 5 Installing the Data Analysis ToolPak .......................................................................................... 6 Help ........................................................................................................................................... 6 Computing Exercises #0.................................................................................................................. 7 Arithmetic operations in a spreadsheet (Keller 9th ed. Case 12.1, page 3) .................................... 7 More features and operations .................................................................................................... 10 Computing Exercises #1................................................................................................................ 12 Histograms (Keller 9th ed. Example 3.1, pages 45-48)............................................................... 12 Creating a Histogram ........................................................................................................... 12 Editing a Histogram ............................................................................................................. 12 Sizing the histogram ........................................................................................................ 12 Removing the category "More" from histogram............................................................... 12 Removing the gaps in the histogram ................................................................................ 12 Changing font sizes ......................................................................................................... 13 Relabelling the X-axis ..................................................................................................... 13 Obtaining the frequency numbers in the chart box ........................................................... 13 Pie Charts (Keller 9th ed. Example 2.1, pages 18-22) ................................................................ 13 Descriptive Statistics ................................................................................................................ 13 Steps ............................................................................................................................... 13 Computing Exercises #2................................................................................................................ 15 Binomial Distribution ............................................................................................................... 15 Steps ............................................................................................................................... 15 Normal Distribution.................................................................................................................. 16 Steps ............................................................................................................................... 16 Calculating Binomial and Normal Probabilities ........................................................................ 16 Binomial Distribution ...................................................................................................... 16 Computing Exercises #3................................................................................................................ 18 The sampling distribution of a sample mean and estimation of variance ................................... 18 Experiment 1 ....................................................................................................................... 18 Steps ............................................................................................................................... 18 Experiment 2 ....................................................................................................................... 19 Steps ............................................................................................................................... 19 Experiment 3 ....................................................................................................................... 20 Computing Exercises #4................................................................................................................ 21 1. Scatter Diagrams .................................................................................................................. 21 1

Steps ............................................................................................................................... 21 2. Simple regression ................................................................................................................. 21 Steps ............................................................................................................................... 22 3. Multiple regression ............................................................................................................... 23

Introduction
Students will use the spreadsheet program Excel to solve statistical problems on topics discussed in lectures. Excel output will be discussed in tutorials and lectures and will be required in order to complete a major project. Computing is an integral component of Business and Economic Statistics and you are expected to become proficient in Excel. Given that most students have access to their own personal computers and the Excel program as part of the Microsoft Office package we are not insisting that you attend laboratory sessions on campus in order to become proficient in using this program. You will have the opportunity to either work through a set of preparatory exercises on your own at home or to attempt them at university. For those students who feel they need assistance, specific BES Lab sessions have been booked and can be accessed on a drop in basis. A lab supervisor will be on duty during the following times in Weeks 2-11 and will help students with their computer exercises: Day Tuesday Wednesday Time 11:00 - 13:00 10:00 - 12:00 Place QUAD 1030 QUAD 1030

You may also direct your Excel questions to your tutors. You will be using the Excel spreadsheet running under Windows 2007 at the university but you may have other versions on your home computer which will suffice. The University holds a site licence for Excel. The software need not be purchased for use at the University. Individual copies must, of course, be purchased for home use. You may also find helpful various guidebooks to Microsoft Excel which should be available in the UNSW bookshop. Programs such as Excel are used extensively in business and other fields. In this subject our main aim will be to use Excel to illustrate some of the subject matter covered. Another important aim will be to provide students with basic spreadsheet skills which will be drawn upon and extended in subsequent subjects, and which will be of use in many work situations. The principal advantage of spreadsheets is their capacity to store large quantities of data in a form which facilitates data manipulation, calculations and organisation of the results for more effective analysis and presentation. Windows offers additional flexibility from its graphical features. These computing exercises are divided into several parts: Computing Exercises #0, #1 and #2 are appropriate for use during weeks 1 to 7, while Computing Exercises #3 and #4 will be relevant in weeks 8 to 13. Apart from the computing problems that will be discussed in tutorials, the project, which is worth 20% of your final grade, cannot be successfully completed without using Excel.

Getting started in the University Labs


If you use the labs on campus you need to consult the Student IT resources handbook http://www.asb.unsw.edu.au/currentstudents/resources/forms/Documents/Student%20IT%20handb ook.pdf . This document provides information on setting up an account, logging on and off, storing information and printing.

Becoming familiar with the Excel Worksheet


Windows is an extension of MS-DOS. Its popularity stems mainly from the use of graphical representations (icons) which can be selected with the mouse pointer, rather than words or alphanumeric combinations which must be keyed to initiate specific commands. The use of multiple screens (windows) also assists in achieving a particular sequence of commands.

... To run an application with a mouse, move the mouse pointer to the desired icon and double
click the left mouse button. Note that the two clicks must be done in fairly rapid succession. In the description that follows, an instruction to click the mouse button refers to the left button unless otherwise stated. After double-clicking the Excel icon (the first click highlights the name and the second click activates the command to load the software into the random access memory), wait for the loading operation to be completed. The standard Excel screen will then be displayed.

A workbook is a set of spreadsheets or worksheets. The workbook which appears when the Excel 3

icon is clicked is labelled Book l. Near the bottom of the screen on the Navigation controls, Sheet l will be highlighted, with other sheets appearing along the bar. This enables you to work with multiple sheets and to move from one sheet to another by clicking the appropriate sheet number. In the top left hand corner is the Office button and next to this is the Quick Access Toolbar containing a few frequently used commands. By default, Excel displays a set of task-orientated tabs called the Ribbon. Each tab on the Ribbon contains Groups of similar commands. For example, the Home tab contains a large number of the most frequently used commands grouped together such as cut and paste in the Clipboard group and inserting or deleting in the Cells group. To switch to another tab such as Formulas you click that tab on the Ribbon to find a new selection of grouped commands. Moving Within the Worksheet Numbers are entered into cells which are identified by rectangular boxes outlined in grey lines. The address of a cell consists of a letter to designate a column and a number to designate a row. For example, the address of the elements which might appear in the third column and fifth row is C5. This address must be used in any formula which operates on the numbers in that cell. The letter must appear before the number (column designated before the row) and may be either upper case or lower case. The active cell is identified by a heavy border and its cell address is shown above column A. There are several ways to move about in the worksheet. The ways we will most commonly use are: 1. 2. 3. 4. 5. 6. Using Enter to move down one cell Using the arrow keys ((). Press once to move one cell or hold down until the correct cell is reached. Pointing to a cell with the mouse pointer and clicking the left button. Pressing the F5 key, entering the cell to which you want to go then clicking on OK. Pressing the [Page up] or [Page Down] key to move up or down one window respectively Pressing [Ctrl] + [Home] to move to cell Al. You should quickly try all of these methods.

Selecting Cells or Ranges of Cells Most spreadsheet operations require cells or cell ranges to be selected before the operation can be carried out. You can select (highlight) cells by positioning the mouse pointer in the top left corner of a range, holding down the left mouse button, then dragging down and/or across with the mouse. Note that the top left cell will remain white and the rest of the range will be black. An entire column or row can be selected by clicking when the pointer is positioned on the grey area around the column or row heading. Non-adjacent ranges of cells may be selected by highlighting the first range then holding down the control key while dragging the mouse to highlight a second range. Mouse Pointer The mouse pointer may take on a number of different shapes which indicate various operations, but is most often seen as a thick cross. When the pointer is moved to the bottom right hand corner of the active cell it is shown as a thin cross. This indicates that the AutoFill operation can be carried out by dragging downwards with the mouse. A third shape is assumed when the pointer is moved next to the border of an active cell or selected range. It then becomes an arrow, indicating that the contents of the box can be moved by holding 4

down the left mouse button and dragging to a new position. When a cell is being edited the pointer takes on the shape of the letter I. Correcting Errors 1. If you have typed some characters and have not yet pressed [Enter] use the backspace key to remove them. 2. Point and click on the UNDO button (the backward pointing arrow) on the top quick access toolbar to reverse the last entry. 3. You can type a new entry and press [Enter] to overwrite a cell. 4. You can highlight a cell or cells and press the delete key to remove the contents. 5. You can highlight cells then use the delete cells command from the Home tab to delete a few cells or a whole row or column. 6. If you wish to edit the contents of a cell without erasing you can double click on the cell, use the mouse pointer (I) to move to where the error is, click then add or delete characters. Formatting A wide variety of options are available for the display and for printing. To list a few of these that are available on the Home tab: borders can be created for specific cells, shading can be applied to specific cells, the type face can be changed from default Arial typeface, the size of the type can be changed from the default 10 point, the type can be made bold, Italic or underscored, the numbers can be left aligned, centred, or right aligned, and column width and height can be changed. Saving and retrieving files Once you have set up your spreadsheet you may want to save it for future use. 1. To save a file click on Save button available on the Quick Access toolbar. 2. Choose a filename. It is preferable to use a name which you can easily identify when you have a lot of files. For example for your first laboratory you could use BESLAB1. Excel will automatically add the extension .XLSX (.XLS in older versions). 3 You will see the Save As dialog box. Browse to select a folder on your USB or wherever you plan to save the file, type a name in the File name box, and then click Save. 4 If you have already named the file and wish to save a later version you need only click on the Save button. (It is good practice in a long work session to periodically save the current version of your file.) 6. To retrieve a file, Open Excel, click the Office Button, Click Open, browse to select the folder containing the file, then double click on the file name.

Data files
The data files required for these exercises are Xm02-04.xls, XR02-47.xls, XR17-30.xls and IMPORT.xls and are accessible through the course website using Blackboard. Students should have some means of saving files if they are using the computer labs. A USB flash drive is probably the most practical option. Alternatively, students can email files to themselves or save documents on their faculty network drive.

Installing the Data Analysis ToolPak


The Analysis ToolPak is an Excel add-in program, which must be installed in Excel before it may be used. To install: 1. Click on the Microsoft Office button, and then go to Excel options. 2. Select Add-ins, then Excel add-ins from the Manage drop down box. Click Go. 3. Select the Analysis Toolpak and then OK. You may then be asked to install the ToolPak, click Yes. 4. The Anaylsis ToolPak should now be available in the Data tab in Excel.

Help
There is extensive online help available for Excel at the Microsoft website (http://office.microsoft.com/en-au/assistance/ ). Also while logged on to Excel, access to the built-in help is available by pressing F1 or by clicking on the white question mark in the blue circle in the top right hand corner of the worksheet. All of the procedures covered in this document are explained in further detail in the online help. Students are encouraged to use these resources where they have difficulty. The university also has some material that may be of use including a comparison of recent version of Excel. See http://www.it.unsw.edu.au/staff/training/ms_office_07.html Finally the Keller textbook also includes instructions and examples on the use of Excel in statistics.

Computing Exercises #0
Week 1 or 2 Objectives of this exercise: (i) (ii) (iii) (iv) To become familiar with how to log on to Excel. To become familiar with the spreadsheet screen, commonly used keys and using the mouse. To gain experience in using basic functions. To gain experience in creating and saving a file and opening an existing file.

NOTE: If you already have Excel experience you can safely skip this exercise and move to Computing Exercises #1.

Arithmetic operations in a spreadsheet (Keller 9th ed. Case 12.1, page 3)


To see how addition, subtraction, division and multiplication are carried out we will replicate some calculations made in the textbook. In preparation first read Case 12.1 on p. 3 of Keller. 1. If you are in a Lab first logon to your computer using the instructions in the Student IT Handbook. Now Open Excel so that you have a blank worksheet. If you have not already done so, read the Becoming familiar with Excel Worksheet and: Find the Office button, Quick Access Toolbar, the Ribbon and Navigation controls Switch from the Home tab to each of the other tabs Work through the different ways to move the cursor See how the mouse pointer can take on the shape of a thick and thin cross and an arrow Enter the number 0.5 in the cell A1 and press [Enter] Now move back to A1 and correct the entry to 0.25 2. We are now ready to start the exercise. Make sure the only entry in the worksheet is 0.25 in cell A1. This is the market share assumed in the case. In order to calculate sales per week under the exclusivity agreement we need to enter Pepsis current daily sales in cell A2: 22000 3. Now lets calculate the sales per week under the exclusivity agreement. For this we will need to divide the contents of A2 by A1. For division Excel uses / . Move the cursor to D1. Now type = A2/Al [Enter]

Notice that the formula appears in the formula bar at the top of the spreadsheet as well as in the active cell. D1 now contains the cans per week figure of 88,000.

4. Now enter a few more of the key pieces of information provided as part of this Case and that are the ingredients for further calculations. Enter the price, university take, cost and annual payment to the university in cells A3 to A6: 0.75 5. 0.35 0.2 200000

So that we dont forget what each of the numbers in A1 to A6 represent, lets type names in the next column of cells (B1 to B6): share sales price take cost payment

6. Move the cursor to D2 where we illustrate the use of multiplication. Excel uses the symbol * to indicate multiplication. =Dl*40 [Enter]

D2 now contains the total sales per year of 3,520,000. 7. While it may sometimes be useful to do calculations one step at a time, we can also string calculations together. Suppose we want to calculate gross revenue to Pepsi after subtracting the take. The answer is $1,716,000 which can be found using the following formula that we enter in D3: =D2*A3*(1-A4) [Enter]

8. Now lets calculate the net profit figure of $812,000. Move the cursor to D4 and type: =D3-A5*D2-A6. [Enter]

9. Again we might worry that well forget what cells represent so lets label D1 to D4 by entering names in E1 to E4. sales pw sales pa gross rev net profit

10. You will often want to insert rows or columns into your worksheet. Lets insert a row at the top of the worksheet so that we can add a label. Also we will change the font of this label. Move the cursor over the row number 1 and click, highlighting the entire first row On the Home tab move to the Cells group and click on Insert A new row will be inserted and existing cells will all be moved down In A1 type Base scenario Make sure the cursor is in A1 and click the B (for Bold) button in the font group on the Home tab

11. You have now produced a simple spreadsheet. The worksheet should look like this:

12. Lets save this for possible future use. Click the Save button on the Quick Access toolbar Choose a filename In the Save As dialog box, browse to select a folder and type the chosen name in the File name box Click Save 13. Now log off if finishing this session or continue on with the next exercises.

More features and operations


You should have your spreadsheet saved. Lets open this existing file and explore some more Excel features and functions. As discussed in Case 12.1 Pepsi is somewhat uncertain about their actual market share at the university. The calculations done previously assumed Pepsis market share was 25%. One way to proceed is to use statistics to estimate the market share. This is pursued in Keller Ch 12, p. 444. Here the alternative approach is to ask what if the market share was different from 25%. We will calculate Pepsis net profit under various assumptions about market share. Our spreadsheet is ideally suited for such an exercise because we are doing many very similar calculations. 1. Open your Excel worksheet. Open Excel Click the Office Button Click Open Browse to select the folder containing the file, then double click on the file name 2. Rather than modifying the existing worksheet we will make a copy and modify this copy. Move the cursor to the Sheet 1 tab at the bottom of the worksheet Right click and select Move or copy Check the Create a copy box and click OK You will be in an identical worksheet labelled Sheet 1 (2) 3. Give this new worksheet a different, more descriptive name. Move the cursor to the Sheet 1 (2) tab at the bottom of the worksheet Right click and select Rename Type the new name What if Move the cursor to A1 change the header from Base scenario to What if scenario 4. Now suppose we assume the share is 0.4 not 0.25. To do this calculation: Move the cursor and click on A2 Type 0.4 The cells D2 to D5 will all change because these calculations involve the share which has changed. 10

5. Similarly the values for each of the key inputs could be changed so that the sensitivity of net profit could be gauged. Move the cursor, click on A4 and type 0.8. 6. Excel has a number of automated functions that perform many useful tasks including summing, taking logs, etc. Click the Formulas tab and browse to get a sense of what is available. On this tab the button on the Function library group in the Insert function button denoted by f x . This is called the Function Wizard. Notice that just below there is a short cut to this button that appears no matter what tab you are in. We will use this Function Wizard to insert a logical function that will automate the comparison of the current annual profit of $484,000 to the profit calculated under whatever scenario we choose. Move the cursor to E6 and type decision Move the cursor to D6 and click on the f x button In the Or select a category box select Logical In the Select a function box select IF and press OK You now are prompted for 3 function arguments For Logical_test type D5>484000 For Value_if_true type Yes For Value_if_false type No and press OK 7. Save the completed file. Click the Save button on the Quick Access toolbar Choose a filename In the Save As dialog box, browse to select a folder and type the chosen name in the File name box Click Save Discussion question 0.1 i) What is the new value for net profit obtained in step 4? ii) If their current market share were in fact 40% would Pepsi gain from entering in an exclusivity agreement with the university? Why? iii) If their current market share was in fact 40% but Pepsi were able to increase price to $0.80 without affecting demand, would your answer to (ii) change? Why might we be wary about the second assumption that demand doesnt change?

11

Computing Exercises #1
Week 2, 3 or 4 The objectives of this tutorial: i) To gain experience in using Excel graphics to summarize the information contained in large sets of quantitative data. ii) To obtain and interpret descriptive statistics which summarise quantitative data.

Histograms (Keller 9th ed. Example 3.1, pages 45-48)


In this exercise, you will construct a frequency distribution of long distance telephone bills assuming that eight class sizes have been chosen. Given the data, the class width then becomes 15.

Creating a Histogram
1. Open file Xm02-04.xls. 2. Type Bin in cell B1. 3. In B2 type the upper limit of the first interval which is 15. In B3 type the upper limit of the second interval which is 30. Drag B2 and B3 to complete the listing of Bin. The numbers 45, 60, 75, 90, 105 and 120 should appear in Cells B4 to B9. 4. In the Data tab click on Data Analysis, Histogram, OK. 5. In the dialog box, enter the following information: a) Type the location of the data in the Input Range (including the cell containing the label Bills) as A1:A201 b) Input the Bin Range (including cell B1 containing the label Bin) as B1:B9. c) Since variable names have been included with the data, click the box to enable Labels. d) Click Output Range and type C1. The output will be placed beginning in column C1. e) Click on Chart Output and then click OK. This will produce a frequency distribution and histogram beginning in column C1.

Editing a Histogram
Sizing the histogram
The histogram appears too small in size. To remedy this, click on the white area in chart box. Notice that black squares now appear and that Data is replaced by Chart on the menu bar. The appearance of the small black squares indicates that you can edit the chart, that is, that you are in Chart Edit mode. Go to the small middle black square under Bin. A small arrow pointing upwards and downwards appears. Press left mouse button, a small cross appears. Keep mouse button down and move downwards until you reach, say, Row 20. Then release the mouse button. You can go sideways in the same manner.

Removing the category "More" from histogram


Go to the cell More in the Bin column and highlight the "0" frequency as well. Press delete on the key board.

Removing the gaps in the histogram


Right-click on any of the bars of the Histogram and select Format Data Series. In the Series Options set Gap Width to zero.

12

Changing font sizes


To change the font size of the X-axis numbers, right-click anywhere on the axis. A pop-up box (above the normal right-click options) will display options to alter the size, colour, font etc. of the text. Alternatively, you may select the axis by clicking on it then go to the Home tab to format the text. You may do the same for the Y-axis, legend and Chart title and labels.

Relabelling the X-axis


Click on the X-axis label (Bin) then click the cursor into the label box to change the title to Bills. The text may also be formatted in the Home menu as above. You may do the same for the Y-axis.

Obtaining the frequency numbers in the chart box


Right-click on any of the bars of the Histogram and select Add Data Labels. You may then format the data labels as with the other labels. Save the file.

Pie Charts (Keller 9th ed. Example 2.1, pages 18-22)


In Example of Keller, beginning on page 18, the work status in the GSS Survey of 2008 of 150 respondents is given (the raw data is at the top of page 19). The results are summarized in Table 2.1, also on page 19. Create a pie chart of this data. 1. Click on the Microsoft Office button, New, Create. 2. Type the number of respondents with each type of employment status in column A beginning in cell A1 (entering 1 in this cell and so on). 3. Highlight the data then go to the Insert tab, select Pie Chart from the Chart menu and select the first chart type. 4. The legend will label each data group as 1, 2, 3 and so on. You may change these by clicking on the number 1 to change its label. Do the same with the rest of the legend. 5. Alternatively, you may wish to label each of the groups on the chart itself to make the labelling clearer. Delete the legend by right clicking on it and selecting Delete. Right click anywhere on the pie chart and select Add Data Labels. The numbers of each sector are shown. To change this right click on any of the numbers and select Format Data Labels then in Label Options, Label Contains select categories and percentage, also deselect value.

Descriptive Statistics
In this exercise you will learn how to calculate descriptive statistics for the rate of return on an individual stock and the rate of return on the overall stock market. Open file XR02-47.xls (Column A stores the monthly percentage rate of return on American Barrick Resources (ABX), which is the largest gold producer in North America, and Column B contains the monthly percentage rate of return on the Toronto Stock Exchange 300 Index.) You will use descriptive statistics to provide a numerical summary of these two variables.

Steps
1. Click the Data tab, Data analysis, Descriptive statistics, OK.

13

2. In the dialog box, type the Input Range (include the cells containing variable names) as A1:B61. Select Grouped By Columns. Click Labels in First Row. Specify the Output Range as D1. 3. Click Summary Statistics and then click OK. 4. To improve the appearance of the output, widen the columns. 5. Save the file. Discussion question 1.1 Explain the meaning of Skewness in this context and provide a careful discussion of the risk of holding ABX stock as against a market tracker. (Your discussion should compare the average rates of return and their standard deviations.)

14

Computing Exercises #2
Week 6, 7 or 8 The objectives of this tutorial: 1. To generate random numbers from Binomial and Normal distributions and to examine the results. 2. To calculate Binomial and Normal probabilities. Before attending this lab session, students should re-read Part 1 of the Computing Exercises for the previous exercise on drawing histograms.

Binomial Distribution
In this experiment, you will generate 1,000 observations from a Binomial distribution with parameters p=0.01 and n=100, draw a histogram of the data and generate some descriptive statistics.

Steps
1. Click the Data tab, Data analysis, Random number generation, OK. 2. In the dialog box: a) Type 1 to specify Number of Variables. b) Type 1000 to specify the number of Random Numbers. c) Set the Distribution to Binomial. d) Set p value to 0.01 and Number of trials to 100. e) Click on the Ouput Range button and specify output range as A1. Click OK 3. Type the numbers 0 and 1, respectively, in B1 and B2. Drag B1 and B2 to B7 to complete the listing of the Bin (upper limits of classes). The numbers 2,3,4,5,6 should appear in cells B3 to B7. 4. Click the Data tab, Data analysis, Histogram, OK. a) In the dialog box, enter the following information Specify Input Range as A1:A1000. b) Specify Bin Range as B1:B7. (Do not select Labels). c) Click Output Range and type C1. d) Click on Chart Output. Then click OK. 5. Improve the appearance of the histogram. 6. Click the Data tab, Data analysis, Descriptive statistics, OK. In the dialog box enter the following information: a) Specify Input Range as A1:A1000. b) Click the Output Range button and specify Output Range as B15. c) Click on Summary Statistics and then OK. 7. To improve the appearance of the output, widen the columns. 8. After discussion, click on Sheet 2 at the bottom of the screen to do the next experiment. Discussion question 2.1 i) Describe the shape of the histogram. Is it symmetric? ii) Are the mean and standard deviation computed in this experiment what you anticipated? (Note that for the binomial distribution = np and 2 = np(1-p). 15

Normal Distribution
You will now generate 1,000 observations from a Normal Distribution with mean of 50 and a standard deviation of 5. Repeat the first experiment with the following changes:

Steps
1. Set the Distribution to Normal. 2. Set Mean to 50 and Standard Deviation to 5. 3. Type the numbers 40 and 45, respectively, in B1 and B2. Drag B1 and B2 to B6 to complete the listing of the Bin (upper limits of classes). The numbers 50, 55, 60, 65 should appear in cells B3 to B6). Note that for a bell shaped distribution, 99% of the data values fall within three standard deviations of the mean, that is, fall within the interval (35, 65) in this case. 4. Specify Bin Range as B1:B6. 5. After discussion (directly below), save the output of Sheets 1 and 2. Discussion question 2.2 i) Does the histogram look the way you expected? ii) Why doesnt the histogram appear exactly bell shaped? iii) Are the mean and standard deviation computed in this experiment what you anticipated?

Calculating Binomial and Normal Probabilities


To calculate Binomial Probabilities, proceed as follows: 1. Click on the f x button, then set the Function category to Statistical and then Function name to BINOMDIST. Click OK. 2. Use the cursor and type the value of x (number_s), the number of n (trials), the probability of success p (probability_s), and true (cumulative). This will produce P( X x) . If you type false (cumulative), Excel will compute P(X=x). When you do the questions below, you will notice that, when you click OK, once Excel has calculated a probability for you, this probability answer is placed in the current active cell and the formula appears in the white bar above the column labels. Use Excel to calculate the following probabilities:

Binomial Distribution
A pair of dice is rolled 180 times. The probability of getting a 7 on a single throw is 0.167. What is the probability that a total of 7 occurs: 1. 2. 3. 4. fewer than 25 times? at least 25 times? between 33 and 41 times inclusive? exactly 30 times? (0.1319) (0.8681) (0.2934) (0.0796)

16

To calculate normal probabilities, proceed as follows: 1. Click on the f x button, then select Statistical as the Function category. 2. Select one of the following from Function name: a) STANDARDIZE(X, , ) computes the Z value for given values of X, and ; b) NORMSDIST(Z) computes the probability less than a given Z value; c) NORMSINV(Probability) computes the Z value corresponding to a given cumulative area under the normal curve; d) NORMDIST(X, , ,True) computes the probability less than a given X value; e) NORMINV(Probability, , ) computes the X value corresponding to a given cumulative area under the normal curve. As you do the questions below, you will notice that when you click OK, Excel places the probability it calculates in the current active cell and the formula appears in the white bar above the column labels. For a normal distribution with a mean () of 75 and a standard deviation () of 6, calculate the following using the appropriate function from Excel in each case: 1. 2. 3. 4. 5. The Z value corresponding to X=81; The area below a Z value of 1.0; The Z value corresponding to a cumulative area of 0.025; The area below an X value of 81; The X value corresponding to a cumulative area of 0.025. (1.0) (0.8413) (-1.96) (0.8413) (63.24)

17

Computing Exercises #3
Week 9 or 10 The following problem sheets (#3 and #4) have a computing component and associated discussion. Some problems relate to tutorial problems that will be encountered in the last third of the course. The objectives of these problems: 1. To generate the sampling distribution of the sample mean; 2. To demonstrate what is meant by an unbiased estimator;

The sampling distribution of a sample mean and estimation of variance


Experiment 1
Recall that for a fair die, each number from 1 to 6 is equally likely (the probability of each outcome is 0.16666). From the discrete probability function representing the toss of a fair die, the population mean is 3.5 and the population variance is 2.92. Suppose you toss a die twice and then calculate the mean of the two numbers you obtained. Suppose you do this 1000 times. In other words, the experiment is to toss a die twice, calculate the mean of the two numbers and perform this experiment 1000 times. Having performed this experiment, you will then describe the sampling distribution of the sample mean. You will perform this experiment in Excel. The experiment will generate 1000 integers between 1 and 6 in two columns. A third column stores the sample means from each row. The sampling distribution of the mean is described numerically and graphically.

Steps
1. You are going to create your own discrete probability distribution. In cell A1, store the numbers 1, 2, 3, 4, 5, 6. 2. In cell B1, store the formula =1/6 to indicate the 1/6 probability of rolling a 1. Drag this formula down to cell B6. Now columns A and B contain the discrete distribution representing the toss of a fair die. 3. Click the Data tab, Data analysis, Random Number Generation, OK. 4. A dialog box now appears. In the dialog box: a) Type 2 to specify the Number of Variables. (There are two random variables in this experiment. The first random variable assumes numbers from the first toss of the die while the second random variable assumes numbers from the second toss of the die). b) Hit tab and type 1000 to specify the Number of Random Numbers. (You specify 1000 because the experiment is repeated 1000 times). c) Select the Discrete distribution. d) In the Parameters Box type A1:B6 to specify the Value and Probability Input Range of the distribution. e) Click on the Output Range. Specify output range as C1. f) Click OK. Columns C and D will now fill with the random numbers you generated from the discrete distribution 5. Go to the next available column (which is column E) to create a column of means. Type =Average(C1:D1) in cell E1 and press enter. Excel will calculate the mean of the numbers in C1 and D1 and store it in E1. 18

6. Drag column E from E1 to E1000 (you may also double click on the bottom right corner of cell E1 and Excel will auto-fill down to E1000). Column E will contain the averages of the two die tosses. 7. You will now calculate descriptive statistics for the sample means (which are in column E). This allows you to characterize numerically the sampling distribution of the sample means. Click the Data tab, Data analysis, Descriptive statistics, OK. In the dialog box: specify Input Range as E1:E1000; click on Output Range and specify as F1; click Summary Statistics and OK. To improve the appearance of the Summary Statistics, widen the columns 8. You are now going to draw the histogram of the sample means. Type 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0 in cells H1 to H11. 9. Click the Data tab, Data analysis, Histogram, OK. Specify Input Range as E1:E1000; Bin Range H1:H11; Output Range F20. Click on Chart Output. Click OK. 10. After answering the discussion questions directly below, click on Sheet 2 at the bottom of the screen to do the next experiment. Discussion question 3.1 i) What do you expect the mean and variance of the sampling distribution of the mean to be? (Recall X ~ N ( , 2 / n) ). ii) What did the computer calculate as the mean and variance of the sampling distribution of the mean? Are those numbers consistent with what you expected? iii) Did you expect the histogram to appear bell shaped and symmetric?

Experiment 2
The purpose of this experiment is show that the sample variance s 2 = is an unbiased estimator of the population variance 2. You will generate 300 samples of size 4 from a normal population whose mean is 50 and whose variance is 25 (standard deviation is 5). For each sample of size 4 (there are 300 of these), you will calculate the sample variance. Then you will calculate the mean of the 300 sample variances. You 2 will then be able to see whether s is an unbiased estimator of 2. Steps 1. Click the Data tab, Data Analysis, Random Number Generation, OK. 2. Type 4 in the dialog box to specify the Number of Variables. (In a sample of size 4, each of the 4 outcomes is a realization of a random variable. Therefore, there are 4 random variables). 3. Hit tab and type 300 to specify the Number of Random Numbers. (Here you are stating that the number of samples (each of size 4) is 300). 4. Select the Normal distribution. 5. In the Parameters Box type 50 to specify the mean and 5 to specify the standard deviation. Click on the Output Range and specify as A1. Click OK. (It may take the computer you are using a few moments to generate these numbers). The four numbers in each row (in columns A to D) are the realizations of a random sample of size 4 from a normal distribution with mean 50 and variance 25. There are 300 rows of numbers since there are 300 samples of size four. 19

(X
i =1

X )2

n 1

6. Go to the next available column (which is column E) and create a column of sample variances. Type =VARA(A1:D1) in cell E1 and press enter. Excel will calculate the sample variance of the numbers in A1 to D1 (i.e. of the numbers in the first sample) and store it in E1. 7. Drag column E from E1 to E300. Column E will contain the sample variances for each sample. 8. You are now going to calculate the mean of the 300 sample variances. Click Data, Data Analysis, Descriptive Statistics, OK. In the dialog box specify: Input Range E1:E300; click on Output Range and specify as F1; click Summary Statistics and OK. To improve the appearance of summary statistics widen the columns. (Note: The mean that you have calculated here is average of the 300 sample variances in column E). 9. Do not save your worksheet yet as you will need your current work for the next experiment. Before proceeding to the next experiment, answer the following discussion questions. Discussion question 3.2 i) If the sample variance is an unbiased estimator of the population variance, what would you expect the sample variance to be on average? ii) What did the computer give as the mean of the sample variances? iii) Does it appear that the sample variance is an unbiased estimator of the population variance?

Experiment 3
The purpose of this experiment is to show that the statistic s 2 =
2 of the population variance .

(X
i =1

X )2 is a biased estimator

Your worksheet from experiment 2 should still be on the computer screen. (If not, find your saved copy). Continuing on
2 10. Go to column H1 and type =E1*0.75. (Here you are multiplying the sample variance s in E1 2 by [(n-1)/n] = so you are calculating the statistic s ).

2 11. Drag H1 to H300. Column H will now contain the statistic s calculated for each sample (of size 4). Because there are 300 samples, there are 300 values of this statistic in column H. 2 You are now going to calculate the mean of s . Click Data, Data Analysis, Descriptive Statistics, OK. In the dialog box specify: Input Range H1:H300; Click on Output Range and specify as I1; click on Summary Statistics and OK.
After answering the following discussion questions, save the output of Sheets 1 and 2. Discussion question 3.3 2 2 i) If s is an unbiased estimator of the population variance, what would you expect s to be on average? 2 ii) What did the computer give as the mean of s ? 2 iii) Does it appear that s is an unbiased estimator of the population variance? iv) Why do you suppose a sample size of only four was specified in this experiment? (Hint: What happens to [(n-1)/n] as n becomes large?).

20

Computing Exercises #4
Week 11 or 12 The objectives of this exercise are: 1. To plot scatter diagrams; 2. To estimate linear regression models; 3. To interpret output from simple and multiple regression.

1. Scatter Diagrams
In this exercise, you will investigate the relationship between the rate of return on an individual stock and the rate of return on the overall stock market (recall the previous analysis you undertook under the heading Descriptive Statistics) by means of a scatter diagram and, later, a regression model.

Steps
2. Open file XR17-30.xls (Column A stores the monthly percentage rate of return for Intel Corporation stock and Column B stores the monthly percentage rate of return for the overall market (measured by the Standard and Poors Composite Index) for the period January 1993 to December 1996. Note that the variable to appear on the vertical axis must be in the second column. 3. Highlight the data range A1:B49 then click the Insert tab and in the Charts menu select Scatter and the first chart option. 4. Click on the chart to open the Design menu at the top of the screen then select the first option from Chart Layouts to add a heading and labels. Click on the heading and change it to Returns. Then change the X-axis title to Intel and the Y-axis to S&P. 5. To eliminate the gridlines right click on any gridline and select Format Gridlines. In Line Colour select solid line and change the transparency to 100%. 6. Size the scatter diagram as you did with the histogram. 7. Now right click on the Y-axis and select format axis. Change the major unit to 4 and click OK. 8. Now draw a straight-line through the points. Right click on any data point and select Add Trendline. An options box appears, select Linear and OK. Discussion question 4.1 Based on the information you obtained, describe the relationship between the returns on the individual stock (Intel) and the returns on the overall market (S&P).

2. Simple regression
The market model, assumes that the monthly rate of return on a stock (Rt) is linearly related to the monthly rate of return on the overall stock market (Rm,t). (Note: the subscript t denotes the return in month t). The mathematical description of the model is:
R t = 0 + 1 R m , t + t (1)

where the error term t is assumed to satisfy the requirements of the linear regression model. For practical purposes, Rm,t is taken to be the monthly rate of return on some major stock market 21

index. (The example presented in Keller Section 17.5 uses monthly rates of return for Nortel stock and for the overall market as measured by the Toronto Stock Exchange Index.) The coefficient 1 , called the stocks beta-coefficient, measures how sensitive the stocks rate of return is to changes in the level of the overall market. For example, if 1 >1 ( 1 <1), the stocks rate of return is more (less) sensitive to changes in the level of the overall market than is the average stock. Remember the file XR17-30.xls contains the monthly rates of return for Intel Corporation stock and for the overall market (measured by the Standard and Poors Composite Index), for the period January 1993 to December 1996. (They are stored in columns A and B, respectively, in the file.) You will now estimate the market model (1) as a simple regression.

Steps
1. Open file XR17-30.xls (its the same one you used in the scatter diagram exercise above). The data should appear in columns A and B. 2. Data, Data Analysis, Regression, OK. 3. A dialog box now appears. In the dialog box, specify: a) Input Y Range as A1:A49 b) Input X Range as B1:B49 c) Click on Labels. d) Specify Output Range as C1. 4. Select Residuals, Standardized Residuals and Line Fit Plots. Click OK. The predicted values of the return on Northern Telecom stock, the residuals and standardized residuals will be printed. A plot of the actual and predicted values of the return on Intel stock will also be shown. 5. To improve the appearance of the regression output, widen the columns. 6. To improve the appearance of the chart, click anywhere within the boundaries of the chart-box. Increase the size of the chart. Point the mouse to any number on the Y axis so that Value Y axis appears. Right click and a Format Axis dialog box appears. Click on Number, select number and specify the number of decimal places as 2. Change font size to 8 using the Home tab. Then click OK. Do similarly for the X axis numbers. If you like, further improve the appearance of the chart. Discussion question 4.2 Now consider the following questions: i) What is the sample regression line? ii) Is there sufficient evidence to infer at the 5% significance level that there is a linear relationship between the return on Intel Corporation stock and the return on the total market? iii) Is there sufficient evidence to infer at the 5% significance level that Intel Corporation stock is less sensitive than the average stock? iv) Discuss the significance of the findings? v) Explain the meaning of the regression and residual sum of squares. Save your worksheet.

22

3. Multiple regression
The file IMPORT.XLS contains yearly data on the real value of Australian Imports (column B), the real value of Gross National Expenditure (column C) and the relative price index for the ratio of the price of imports to the domestic price level (column D) over 1970 to 1995 inclusive. Open the file IMPORT.XLS. Estimate the linear regression equation:
Yt = 0 + 1 X 1,t + t

where Yt is imports in year t and X1,t is GNE in year t. Test the hypothesis that 1 = 0 at the 5% level of significance. Explain the economic meaning of the coefficient 1 .
1

Estimate the linear regression equation:


Yt = 0 + 2 X 2,t + t

where X2,t is the relative price index in year t. Test the hypothesis that 2 = 0 at the 5% level of significance. Why would you expect the coefficient on X2,t here to be negative? Both GNE and relative prices are likely to impact on imports implying a multiple regression model:
Yt = 0 + 1 X 1,t + 2 X 2,t + t .

(Here the Input X Range is specified as containing the columns for X1,t and X2,t, that is, specify Input X Range as C3:D28 and do not click on labels under the regression dialog box). Discussion question 4.3 Are the coefficients 1 and 2 statistically different from zero at the 5% level? Of the three regression equations you estimated, which one provides a better explanation of the level of imports?

23

You might also like