You are on page 1of 8

bow83755_app14_001-008.

qxd

9/6/08

10:02 PM

Page 14A-1

Chapter 14
Appendix
Chi-Square Tests Using MINITAB
Appendix 14.2 Chi-Square Tests Using Excel
Appendix 14.3 Chi-Square Tests Using MegaStat
Appendix 14.1

bow83755_app14_001-008.qxd

14A-2

9/6/08

10:02 PM

Chapter 14

Page 14A-2

Chi-Square Tests

APPENDIX 14.1 Chi-Square Tests Using MINITAB


The instruction blocks in this section each begin by
describing the entry of data in the MINITAB Data window.
Alternatively, the data may be loaded directly from the data
disk included with the text. The appropriate data file name
Performing the chi-square test for goodness of fit in Figure 14.1 on page 527 (data
file: MicroWav.MTW):

Enter the microwave oven data from


Tables 14.1 and 14.2 on page 527
observed frequencies in column C1
with variable name Frequency and
market shares (entered as decimal
fractions) in column C2 with variable
name MarketShr.

Select Calc : Calculator.

In the Expression window, enter


400*MarketShr and click OK to
compute the expected values.

Select Calc : Calculator.

In the Expression window, enter the


formula (Frequency Expected)**2/
Expected and click OK to compute
the cell chi-square contributions.

Select Calc : Column Statistics.

Enter ChiSq in the Input variable


box.

Enter k1 in the Store result in box


and click OK to compute the chisquare statistic and to store it as the
constant k1.

Select Calc : Probability Distributions :


Chi-Square.

In the Chi-Square Distribution dialogue box, click on Cumulative probability.

Enter 3 in the Degrees of freedom


box.

Click the Input constant option and


enter k1 in the corresponding box.

Enter k2 in the Optional storage


box.

Click OK in the Chi-Square


Distribution dialogue box.

Select Calc : Calculator.

In the Calculator dialogue box, enter Expected in the Store result in


variable box.

Enter ChiSq in the Store result in


variable box.

In the Column Statistics dialogue


box, select Sum.

In the Calculator dialogue box, enter PValue in the Store result in


variable box.

is given at the top of each instruction block. Please refer to


Appendix 1.1 for further information about entering data,
saving data, and printing results.

bow83755_app14_001-008.qxd

17/6/08

7:50 PM

Page 14A-3

Appendix 14.1 Chi-Square Tests Using MINITAB

14A-3

In the Expression window, enter the formula


1  k2, and click OK to compute the p value
related to the chi-square statistic.

Select Data : Display Data.


Enter PValue in the Columns, constants, and
matrices to display window and click OK.

Sum of ChiSq (=8.77857) is the chi-square statistic, and PValue (=0.0323845) is the corresponding p value.
Constructing a contingency table and performing
the chi-square test for independence in Figure
14.4(b) on page 538 (data file: Invest.MTW):

In the Data window, enter the investment


customer satisfaction data from Table 14.9
(page 537)fund type in column C1 with
variable name FundType and level of satisfaction in column C2 with variable
name SatRating.

The default ordering for the different levels of


each categorical variable in the cross-tabulation
table will be alphabeticalthat is, Bond, Stock,
and TaxDef for FundType and High, Low, and
Med for SatRating. To change the ordering to
High, Med, and Low for SatRating:

Click on any cell in column C2 (SatRating).

In the Define an order (one value per line)


window, specify the order High, Med, Low.

Click OK in the Value Order for C2


(SatRating) dialogue box.

Select Editor : Column : Value order.


In the Value Order for C2 (SatRating) dialogue
box, click the User-specified order option.

Constructing the cross-tabulation table and


performing a chi-square test:

Select Stat : Tables : Cross Tabulation and


Chi-Square.

In the Cross Tabulation and Chi-Square


dialogue box, enter FundType in the
Categorical variables: For rows box.

Enter SatRating in the Categorical


variables: For columns box.

Check the Display Counts, Row percents, and Column percents checkboxes.

Click on the Chi-Square button.

Click OK in the Cross Tabulation


Chi-Square dialogue box.

Click OK in the Cross Tabulation and ChiSquare dialogue box to obtain results in
the Session window.

In the Cross TabulationChi-Square dialogue box, check the Chi-Square analysis


and Expected cell counts checkboxes.

The chi-square statistic can also be calculated


from summary data by entering the cell counts
from Figure 14.4(b) and selecting Chi-Square
Test (Table in Worksheet) from the Stat : Tables
submenu.

bow83755_app14_001-008.qxd

14A-4

17/6/08

7:50 PM

Chapter 14

Page 14A-4

Chi-Square Tests

APPENDIX 14.2 Chi-Square Tests Using Excel


The instruction blocks in this section each begin by
describing the entry of data in an Excel spreadsheet.
Alternatively, the data may be loaded directly from the
data disk included with the text. The appropriate data file
Performing the chi-square goodness of fit
test in Exercise 14.10 on page 535 (data
file: Invoice2.xls):

In the first row of the spreadsheet,


enter the following column headings
in orderPercent, Expected, Number,
and ChiSqContribution.

Beginning in cell A2, enter the


Percentage of Invoices figures from
Exercise 14.10 as decimal fractions in
column A.

Compute expected values. Enter the


formula =500*A2 in cell B2 and press
Enter. Copy this formula through cell
B6 by double-clicking the drag handle
in the lower right corner of cell B2.

Enter the Number of Invoices


figures from Exercise 16.10 in cells
C2 to C6.

Compute cell chi-square contributions. In cell D2, Enter the formula


=(C2 B2)^2/B2 and press Enter. Copy
this formula through cell D6 by
double-clicking the drag handle in
the lower right corner of cell D2.

Compute the chi-square statistic in cell


D8. Use the mouse to select the range
of cells D2 to D8 and click the a
button on the Excel toolbar.

Click on an empty cell, say cell B24,


and select the Insert Function button fx on the Excel toolbar.

In the Insert Function dialogue box,


select Statistical from the Or select
a category menu, select CHIDIST
from the Select a function menu,
and click OK.

In the CHIDIST Function Arguments


dialogue box, enter D8 in the X box
and 3 in the Deg_freedom box.

Click OK in the CHIDIST Function


Arguments dialogue box to produce
the p value related to the chi-square
statistic in cell B24.

name is given at the top of each instruction block. Please


refer to Appendix 1.2 for further information about entering data, saving data, and printing results.

bow83755_app14_001-008.qxd

19/6/08

3:30 PM

Page 14A-5

Appendix 14.2 Chi-Square Tests Using Excel

14A-5

Constructing a contingency table and performing a


chi-square test for independence similar to Figure
14.4(b) on page 538 (data file: Invest.xls):

Enter the investment customer satisfaction data


from Table 14.9 (page 537) with the fund type
in column A (with label FundType) and the level
of satisfaction in column B (with label SRating).

Building a contingency table (using the PivotTable


and PivotChart Wizard):

Click on cell A1.

In the PivotTable and PivotChart WizardStep


2 of 3 dialogue box, the range A1 to B101 should
already be selected (if not, select it). Click Next.

Select the Existing worksheet option in the


PivotTable and PivotChart WizardStep 3 of 3
dialogue box, enter D1 in the box, and click Finish.

Now use the mouse to drag items in the Pivot


Table Field List to the Pivot Table Report. Drag
FundType to the Drop Row Fields Here area,
and drag SRating to the Drop Column Fields
Here area. Then also drag SRating to the Drop
Data Items Here area.

Select Data : PivotTable and PivotChart Report.


In the PivotTable and PivotChart
WizardStep 1 of 3 dialogue box, select the
Microsoft Office Excel list or database option
and then click Next.

Computing a table of expected values:

In cell E9, type the formula =$H3*E$6/$H$6 (be


very careful to include the $ in all the correct
places) and press Enter (to obtain the expected
value 12 in cell E9).

Click on cell E9 and use the mouse to point the


cursor to the drag handle in the lower right corner of the cell. The cursor will change to a black
cross. Using the black cross, drag the handle
right to cell G9 and release the mouse button to
fill cells F9 to G9. With E9 to G9 still selected, use
the black cross to drag the handle down to cell
G11. Release the mouse button to fill cells E10
to G11.

To add marginal totals, select the range E9 to H12


and click the a button on the Excel toolbar.

Computing the chi-square statistic:

In cell E15, type the formula =(E3 E9)^2/E9


and press Enter to obtain the cell contribution
0.75 in E15.

Click on cell E15 and (using the procedure described above) use the black cross cursor to
drag the cell handle right to cell G15 and then
down to cell G17 (obtaining the cell contributions in cells E15 to G17).

To add marginal totals, select the range E15 to H18


and click the a button on the Excel toolbar.

The chi-square statistic is in cell H18 (= 46.4375).

bow83755_app14_001-008.qxd

14A-6

17/6/08

7:50 PM

Chapter 14

Page 14A-6

Chi-Square Tests

Computing the p value for the chi-square


test of independence:

Click on an empty cell, say H25.

In the Insert Function dialogue box,


select Statistical from the Or select
a category menu, select CHIDIST
from the Select a function menu,
and click OK.

In the CHIDIST Function Arguments dialogue box, enter H18 in the X box
and 4 into the Deg_freedom box.

Click OK in the CHIDIST Function


Arguments dialogue box to produce
the p value related to the chi-square statistic in cell H25.

Select the Insert Function button fx


on the Excel toolbar.

APPENDIX 14.3 Chi-Square Tests Using MegaStat


The instructions in this section begin by describing the entry of data in an Excel worksheet. Alternatively, the data
may be loaded directly from the data disk included with
the text. The appropriate data file name is given at the top
Constructing the contingency table and performing the chi-square test for independence in Figure 14.4(a) on page 538 (data file:
Invest.xls):

Enter the investment satisfaction survey


data in Table 14.9 (page 537) with the
type of investment fund in column A
(with label FundType) and the level of
customer satisfaction in column B (with
label SRating).

Type the labels BOND, STOCK, and


TAXDEF in cells C3, C4, and C5. These
labels will specify the row categories in
the contingency table.

Type the labels HIGH, MED, and LOW in


cells D3, D4, and D5. These labels will
specify the column categories in the
contingency table.

Select MegaStat : Chi-Square/Crosstab :


Crosstabulation.

In the Crosstabulation dialogue box,


click in the Row variable data range
box and use the AutoExpand feature to
enter the range A1 to A101. This defines the variable FundType to be the
row variable in the contingency table.

Click in the Row variable specification


range box and drag the mouse to enter the range C3 to C5. The labels in this
range specify the categories for the row
variable FundType in the contingency
table.

Click in the Column variable data


range box and use the AutoExpand

of each instruction block. Please refer to Appendix 1.2 for


further information about entering data and saving and
printing results in Excel and Appendix 1.3 for more information about using MegaStat.

bow83755_app14_001-008.qxd

9/6/08

10:02 PM

Page 14A-7

Appendix 14.3 Chi-Square Tests Using MegaStat

14A-7

feature to enter the range B1 to B101. This defines the variable SRating to be the column
variable in the contingency table.

Click in the Column variable specification range


box and drag the mouse to enter the range D3 to
D5. The labels in this range specify the categories
for the column variable SRating in the contingency table.

In the Output Options list, check the Chisquare checkbox to obtain the results of the
chi-square test for independence.

In the Output Options list, check the following


checkboxes: % of row, % of column, and %
of total.

Click OK in the Crosstabulation dialogue box.

Conducting the chi-square goodness of fit


test for the scanner panel data in Exercise
14.8 on page 534 (data file: ScanPan.xls):

Enter the scanner panel data in Exercise


14.8 (page 534) as shown in the screenshot, with the number of purchases for
each brand in column C and the market
share for each brand (expressed as a percentage) in column D. Note that the total
number of purchases for all brands equals
19,115 (which is in cell C11).

In cell E4, type the cell formula


=D4*19115 and press Enter to compute
the expected frequency for the Jif/18
ounce brand/size combination. Copy this
cell formula by double-clicking the drag
handle in the lower right corner of cell
E4 to compute the expected frequencies
for each of the other brand/size combinations in cells E5 to E10.

Select MegaStat : Chi-square/Crosstab :


Goodness of Fit Test.

In the Goodness of Fit Test dialogue


box, click in the Observed values input
range box and enter the range C4 to
C10. Enter this range by dragging with
the mousethe AutoExpand feature
cannot be used in the Goodness of Fit
Test dialogue box.

Click in the Expected values input


range box, and enter the range E4 to
E10. Again, enter this range by dragging
with the mouse.

Click OK in the Goodness of Fit Test


dialogue box.

bow83755_app14_001-008.qxd

14A-8

17/6/08

7:50 PM

Chapter 14

Page 14A-8

Chi-Square Tests

Conducting a chi-square test for independence with contingency table input data in
the graduate degree situation of Exercise
14.17 on page 542 (data file: GradSchool.xls):

Enter the data just as you see it in the


question on page 542.

Select MegaStat : Chi-square/Crosstab :


Contingency Table.

In the Contingency Table Test for


Independence dialogue box, click in the
Input range box and (by dragging the
mouse) enter the range. Note that the
entered range may contain row and
column labels, but the range should not
include the row or column total.

In the Output Options list, check the


Chi-square checkbox to obtain the
results of the chi-square test for independence.

In the Output Options list, check the


following checkboxes: % of row, %
of column, and % of total.

Click OK in the Contingency Table Test


for Independence dialogue box.