You are on page 1of 13

Excel Tutorial: Chi-Squared Tests

22-Feb-05

"Essential Mathematics & Statistics for Science" by Dr G Currell & Dr A A Dowman

Link to the different Worksheets by using the Tabs at the foot of this page.

Cells for data entry are normally highlighted in yellow

Cells that contain calculations are normally highlighted in turquoise

Calculations for some cells are sometimes displayed in nearby cells in bold

View the equation or function used for any calculation made in a cell by
- the calculation will appear in the 'formula bar' just below the toolbars at the top

Freq: Chi-squared test to compare oberved frequencies


with an expected ratio of frequencies
Contingency: Chi-squared test to test for an association
between two factors in a contingency table
Yates: Yates correction for a chi-squared test when

Critical Values: Table of critical chi-squared values


urrell & Dr A A Dowman (John Wiley & Sons)

oot of this page.

hted in turquoise

d in nearby cells in bold

on made in a cell by clicking on that cell.


below the toolbars at the top of the spreadsheet.

are oberved frequencies


equencies
or an association
ontingency table
squared test when df = 1
Test for Frequencies

Refer to Unit 11.1 in "Essential Mathematics & Statistics for Science"

Excel Function: CHITEST(Obs, Exp) returns the upper 1-tailed p-value for a c 2-test.
Note CHITEST does not use the Yates correction for df = 1

Excel Function: CHIDIST(c STAT, df) returns the upper 1-tailed p-value for a given value of

Excel Function: CHIINV(a ,df) returns the upper 1-tailed critical value for c 2 for a given signific

Obs, Exp: Identify the ranges containing the Observed and Expected valu
c 2: Chi-squared value
df: Degrees of freedom
a : Significance Level

Using data from Example E11.3:

Category i AB Ab aB ab
Observed Frequency O: 131 28 32 9
Ratio: 9 3 3 1

1 Expected Frequency E = 112.5 37.5 37.5 12.5

=$J20*F21/$J21

2 Chi-squared value = 3.04222 2.40667 0.80667 0.98

=(F20-F23)^2/F23

Chi-Squared Statistic = 7.23556 =SUM(F27:I27)

Degrees of Freedom, df = 3 =4-1

Significance Level, a = 0.05

Critical Chi-Squared Value = 7.81473 =CHIINV(G35,G33)

p-value using CHIDIST = 0.06476 =CHIDIST(G31,G33)

p-value using CHITEST = 0.06476 =CHITEST(F20:I20,F23:I23)


e for a c 2-test.
n for df = 1

or a given value of c 2.

or c 2 for a given significance level.

erved and Expected values

Totals
200
16

200

7.23556

V(G35,G33)

ST(G31,G33)

ST(F20:I20,F23:I23)
Contingency Test

Refer to Unit 11.2 in "Essential Mathematics & Statistics for Science"

Excel Function: CHITEST(Obs, Exp) returns the upper 1-tailed p-value for a c 2-test.
Note CHITEST does not use the Yates correction for df = 1

Excel Function: CHIDIST(c STAT, df) returns the upper 1-tailed p-value for a given value of

Excel Function: CHIINV(a ,df) returns the upper 1-tailed critical value for c 2 for a given signi

Obs, Exp: Identify the ranges containing the Observed and Expected
c 2: Chi-squared value
df: Degrees of freedom
a : Significance Level

Using data from Example E11.5:

Observed Frequencies
Drug Placebo Totals
Much Improvement 26 7 33 =SUM(D21:E21)
Some Improvement 42 18 60
No Improvement 32 25 57
Totals: 100 50 150 =SUM(F21:F23)

1 Calculate Row and Column Totals as above:

2 Calculate Expected Frequencies as above using equation [11.5]

3 Calculate chi-squared values using [11.1]:

Calculation: 0.727 1.455 =(E21-J21)^2/J21


0.100 0.200
0.947 1.895

Chi-Squared Statistic = 5.324 =SUM(E32:F34)

Degrees of Freedom, df = 2 =(3-1)*(2-1)

Significance Level, a = 0.05

Critical Chi-Squared Value = 5.991465 =CHIINV(F40,F38)


p-value using CHIDIST = 0.069811 =CHIDIST(F36,F38)

p-value using CHITEST = 0.069811 =CHITEST(D21:E23,I21:J23)


ue for a c 2-test.
ction for df = 1

for a given value of c 2.

for c 2 for a given significance level.

Observed and Expected values

Expected Frequencies
Drug Placebo
22 11 =E$24*$F21/$F$24
40 20
38 19
D21:E23,I21:J23)
Yates Correction

Refer to Sections 11.1.3 and 11.2.3 in "Essential Mathematics & Statistics for Science"

Excel Function: CHITEST(Obs, Exp) returns the upper 1-tailed p-value for a c 2-test.
Note CHITEST does not use the Yates correction for df = 1

Excel Function: CHIDIST(c STAT, df) returns the upper 1-tailed p-value for a given value of

Excel Function: CHIINV(a ,df) returns the upper 1-tailed critical value for c 2 for a given signific

Obs, Exp: Identify the ranges containing the Observed and Expected va
c 2: Chi-squared value
df: Degrees of freedom
a : Significance Level

Using data similar to Question Q11.6:

Observed Frequencies
A B
Positive responses, r = 26 40 66 =SUM(D21:E21)
Number of 'trials', n = 70 50 120
96 90 186 =SUM(F21:F22)

1 Calculate Row and Column Totals as above:

2 Calculate Expected Frequencies as above using equation [11.5]

3 Calculate chi-squared values using Yates correction [11.3]:

Calculation: 1.680 1.792 =(ABS(E21-J21)-0.5)^2/J21


0.924 0.985

Chi-Squared Statistic = 5.381 =SUM(E31:F32)

Degrees of Freedom, df = 2 =(3-1)*(2-1)

Significance Level, a = 0.05

Critical Chi-Squared Value = 5.991465 =CHIINV(F38,F36)


p-value using CHIDIST = 0.067847 =CHIDIST(F34,F36)

p-value using CHITEST = Err:502 =CHITEST(D20:E22,I20:J22)


- Does not use Yates correction
for Science"

ue for a c 2-test.
ction for df = 1

for a given value of c 2.

for c 2 for a given significance level.

Observed and Expected values

Expected Frequencies
A B
34.06452 31.93548
61.93548 58.06452

=$F22*D$23/$F$23

-J21)-0.5)^2/J21
D20:E22,I20:J22)
use Yates correction
Upper Critical Values for the Chi-Squared Distribution

Refer to Chapter 11 in "Essential Mathematics & Statistics for Science"

One-tailed Values

Confidence: 80% 90% 95% 99% 99.9%


Signficance: 0.20 0.10 0.05 0.01 0.001
df
1 1.64 2.71 3.84 6.63 10.83
2 3.22 4.61 5.99 9.21 13.82
3 4.64 6.25 7.81 11.34 16.27
4 5.99 7.78 9.49 13.28 18.47
5 7.29 9.24 11.07 15.09 20.52
6 8.56 10.64 12.59 16.81 22.46
7 9.80 12.02 14.07 18.48 24.32
8 11.03 13.36 15.51 20.09 26.12
9 12.24 14.68 16.92 21.67 27.88
10 13.44 15.99 18.31 23.21 29.59
11 14.63 17.28 19.68 24.72 31.26
12 15.81 18.55 21.03 26.22 32.91
13 16.98 19.81 22.36 27.69 34.53
14 18.15 21.06 23.68 29.14 36.12
15 19.31 22.31 25.00 30.58 37.70
16 20.47 23.54 26.30 32.00 39.25
17 21.61 24.77 27.59 33.41 40.79
18 22.76 25.99 28.87 34.81 42.31
19 23.90 27.20 30.14 36.19 43.82
20 25.04 28.41 31.41 37.57 45.31
21 26.17 29.62 32.67 38.93 46.80
22 27.30 30.81 33.92 40.29 48.27
23 28.43 32.01 35.17 41.64 49.73
24 29.55 33.20 36.42 42.98 51.18
25 30.68 34.38 37.65 44.31 52.62
26 31.79 35.56 38.89 45.64 54.05
27 32.91 36.74 40.11 46.96 55.48
28 34.03 37.92 41.34 48.28 56.89
29 35.14 39.09 42.56 49.59 58.30
30 36.25 40.26 43.77 50.89 59.70
35 41.78 46.06 49.80 57.34 66.62
40 47.27 51.81 55.76 63.69 73.40
45 52.73 57.51 61.66 69.96 80.08
50 58.16 63.17 67.50 76.15 86.66
60 68.97 74.40 79.08 88.38 99.61
70 79.71 85.53 90.53 100.43 112.32
80 90.41 96.58 101.88 112.33 124.84
90 101.05 107.57 113.15 124.12 137.21
100 111.67 118.50 124.34 135.81 149.45

You might also like