Vous êtes sur la page 1sur 38

Tests of Goodness of Fit

A goodness-of-fit test is an inferential procedure used to determine whether a frequency distribution follows a claimed distribution. Goodness of fit refers to how close the observed data are to those predicted from a hypothesis Note: The chi square test does not prove that a hypothesis is correct. It evaluates to what extent the data and the hypothesis have a good fit

PROCEDURE FOR CHI-SQUARE GOODNESS OF FIT TEST


1.

Set up the hypothesis for Chi-Square goodness of fit test:

Null hypothesis: In Chi-Square goodness of fit test, the null hypothesis assumes that there is no significant difference between the observed and the expected value. In other words, the data follows a specified distribution. Alternative hypothesis: In Chi-Square goodness of fit test, the alternative hypothesis assumes that there is a significant difference between the observed and the expected value. In other words, the data does not follow a specified distribution.

PROCEDURE FOR CHI-SQUARE GOODNESS OF FIT TEST


2. Compute the value of the test statistic. (Oi Ei ) 2 2 = Ei i =1
k

where: Oi = observed frequency for category i Ei = expected frequency for category i k = number of non empty cells Note: The test statistic has a chi-square distribution with (k c) d.f., where c = the number of parameters to be estimated + 1 provided that the expected frequencies are 5 or more for all categories

PROCEDURE FOR CHI-SQUARE GOODNESS OF FIT TEST


3.

Degree of freedom: In Chi-Square goodness of fit


test, the degree of freedom depends on the distribution of the sample. The following table shows the distribution and an associated degree of freedom: Type of distribution Binominal distribution (if p is estimated) Poisson distribution Normal distribution c 2 2 3 Degrees of freedom n-2 n-2 n-3

PROCEDURE FOR CHI-SQUARE GOODNESS OF FIT TEST


4.

Hypothesis testing: Hypothesis testing in Chi-Square


goodness of fit test is the same as in other tests, like Z- test, ttest, etc. The calculated value of Chi-Square goodness of fit test is compared with the table value corresponding to (k-c) degrees of freedom and at level of significance. If the calculated value of Chi-Square goodness of fit test is greater than or equal to the table value, we will reject the null hypothesis and conclude that there is a significant difference between the observed and the expected frequency. If the calculated value of Chi-Square goodness of fit test is less than the table value, we will accept the null hypothesis and conclude that there is no significant difference between the observed and expected value.

PROCEDURE FOR CHI-SQUARE GOODNESS OF FIT TEST


5. Rejection rule: p-value approach: Reject H0 if p-value < Critical value approach:
Reject H0 if 2
2

where is the significance level and there are k - c degrees of freedom

Example
In 200 flips of a coin, one would expect 100 heads and 100 tails. But what if 92 heads and 108 tails are observed? Would we reject the hypothesis that the coin is fair? Or would we attribute the difference between observed and expected frequencies to random fluctuation?

Null hypothesis: The frequency of heads is equal to the frequency of tails. Alternative hypothesis: The frequency of heads is not equal to the frequency of tails.

Example
2 statistic The calculation of the
Face Heads Tails Total O 92 108 200 E 100 100 200 O-E -8 8 0 (O-E)2 64 64 0
2

(O-E)2/E 0.64 0.64

= 1.28

Conclusion:

2 The critical values of for 1 degree of freedom, with = .05 and = 0.01 are 3.841 and 6.635, respectively. As the calculated value of 2 is less than the table value at both = 0.05 and = 0.01 levels of significance we do not reject the null hypothesis and conclude that the coin is fair. That is, frequency of heads is equal to the frequency of tails.

Example
The president of a major University hypothesizes that at least 90 percent of the teaching and research faculty will favor a new university policy on consulting with private and public agencies within the state. Thus, for a random sample of 200 faculty members, the president would expect 0.90 x 200 = 180 to favor the new policy and 0.10 x 200 = 20 to oppose it. Suppose, however, for this sample, 168 faculty members favor the new policy and 32 oppose it. Is the difference between observed and expected frequencies sufficient to reject the president's hypothesis that 90 percent would favor the policy? Or would the differences be attributed to chance fluctuation?

Null hypothesis: The faculty favouring the new policy is 90 percent Alternative hypothesis: The faculty favouring the new policy is not 90 percent.

Example
2 statistic The calculation of the
Disposition Favour Oppose Total Conclusion: O 168 32 200 E 180 20 200 O-E - 12 12 0 (O-E)2 144 144 (O-E)2/E 0.80
2 = 8.00

7.20

2 The critical values of for 1 degree of freedom, with = .05 and = 0.01 are 3.841 and 6.635, respectively. As the calculated value of 2 is greater than the table value at both = 0.05 and = 0.01 levels of significance we reject the null hypothesis. The faculty favouring the new

policy is not 90 percent

Poisson Distribution
1. Set up the null and alternative hypotheses. H0: Population has a Poisson probability distribution Ha: Population does not have a Poisson distribution
2. Select a random sample and a. Record the observed frequency fi for each value of the Poisson random variable. b. Compute the mean number of occurrences . 3. Compute the expected frequency of occurrences ei for each value of the Poisson random variable.

Poisson Distribution
4. Compute the value of the test statistic.

( f i ei ) = ei i =1
2 k

where: fi = observed frequency for category i ei = expected frequency for category i k = number of categories

Poisson Distribution
5. Rejection rule:
p-value approach:

Reject H0 if p-value <


Critical value approach:

Reject H0 if 2 2
where is the significance level and there are k - 2 degrees of freedom

Poisson Distribution
Example: Troy Parking Garage
In studying the need for an additional entrance to a city parking garage, a consultant has recommended an analysis approach that is applicable only in situations where the number of cars entering during a specified time period follows a Poisson distribution.

Poisson Distribution
Example: Troy Parking Garage A random sample of 100 one-minute time intervals resulted in the customer arrivals listed below. A statistical test must be conducted to see if the assumption of a Poisson distribution is reasonable.
# Arrivals 0 Frequency 0 1 1 2 3 4 5 6 7 8 9 10 11 12 4 10 14 20 12 12 9 8 6 3 1

Poisson Distribution
Hypotheses
H0: Number of cars entering the garage during a one-minute interval is Poisson distributed H1: Number of cars entering the garage during a one-minute interval is not Poisson distributed

Poisson Distribution
Estimate of Poisson Probability Function
Total Arrivals = 0(0) + 1(1) + 2(4) + . . . + 12(1) = 600

Estimate of = 600/100 = 6 Total Time Periods = 100 Hence,

6 e f ( x) = x!

x 6

Poisson Distribution
Expected Frequencies
x 0 1 2 3 4 5 6 f (x ) .0025 .0149 .0446 .0892 .1339 .1606 .1606 nf (x ) 0.25 1.49 4.46 8.92 13.39 16.06 16.06 x 7 8 9 10 11 12 Total f (x ) nf (x ) 0 .1377 13.77 0 .1033 10.33 0 .0688 6.88 0 .0413 4.13 0 .0225 2.25 0 .0201 2.01 1.0000 100.00

Poisson Distribution
Observed and Expected Frequencies

i
0 or 1 or 2 3 4 5 6 7 8 9 10 or more

fi
5 10 14 20 12 12 9 8 10

ei
6.20 8.92 13.39 16.06 16.06 13.77 10.33 6.88 8.39

fi - ei
-1.20 1.08 0.61 3.94 -4.06 -1.77 -1.33 1.12 1.61

Poisson Distribution
Rejection Rule
With = .05 and k - p - 1 = 9 - 1 - 1 = 7 d.f. (where k = number of categories and p = number 2 .05 = 14.067 of population parameters estimated), Reject H0 if p-value < .05 or 2 > 14.067.

Test Statistic
(1.20) 2 (1.08) 2 2 = + + 6.20 8.92 (1.61) 2 +. . . = 8.39 3.268

Poisson Distribution
Conclusion Using the p-Value Approach
Area in Upper Tail 2 Value (df = 7) 0.90 0.10 0.05 0.025 0.01 2.833 12.017 14.067 16.013 18.475

Because 2 = 3.268 is between 2.833 and 12.017 in the Chi-Square Distribution Table, the area in the upper tail of the distribution is between 0.90 and 0.10. The p-value > . We cannot reject the null hypothesis. There is no reason to doubt the assumption of a Poisson distribution.

Normal Distribution
1. Set up the null and alternative hypotheses. 2. Select a random sample and a. Compute the mean and standard deviation. b. Define intervals of values so that the expected frequency is at least 5 for each interval. c. For each interval record the observed frequencies 3. Compute the expected frequency, ei , for each interval.

Normal Distribution
4. Compute the value of the test statistic.

( f i ei ) = ei i =1
2 k

5. Reject H0 if 2 2

(where is the significance level

and there are k - 3 degrees of freedom).

Normal Distribution
Example: IQ Computers
IQ Computers manufactures and sells a general purpose microcomputer. As part of a study to evaluate sales personnel, management wants to determine, at a .05 significance level, if the annual sales volume (number of units sold by a salesperson) follows a normal probability distribution.

Normal Distribution
Example: IQ Computers
A simple random sample of 30 of the salespeople was taken and their numbers of units sold are below.
33 64 83 43 65 84 44 66 85 45 68 86 52 70 91 52 72 92 56 73 94 58 63 73 74 98 102 64 75 105

(mean = 71, standard deviation = 18.54)

Normal Distribution
Hypotheses
H0: The population of number of units sold has a normal distribution with mean 71 and standard deviation 18.54. H1: The population of number of units sold does not have a normal distribution with mean 71 and standard deviation 18.54.

Normal Distribution
Interval Definition
To satisfy the requirement of an expected frequency of at least 5 in each interval we will divide the normal distribution into 30/5 = 6 equal probability intervals.

Normal Distribution
Interval Definition

Areas = 1.00/6 = 0.1667

53.02 71 - 0.43(18.54) = 63.03

71

88.98 = 71 + 0.97(18.54) 78.97

Normal Distribution
Observed and Expected Frequencies
i fi ei
5 5 5 5 5 5 30

f i - ei
1 -2 1 0 -1 1

Less than 53.02 6 53.02 to 63.03 3 63.03 to 71.00 6 71.00 to 78.97 5 78.97 to 88.98 4 More than 88.98 6 Total 30

Normal Distribution
Rejection Rule
With = .05 and k - p - 1 = 6 - 2 - 1 = 3 d.f. (where k = number of categories and p = number 2 .05 = 7.815 of population parameters estimated), Reject H0 if p-value < 0.05 or 2 > 7.815.

Test Statistic
(1) 2 (2) 2 (1) 2 (0) 2 ( 1) 2 (1) 2 2 = + + + + + = 1.600 5 5 5 5 5 5

Normal Distribution
Conclusion Using the p-Value Approach
Area in Upper Tail 2 Value (df = 3) .90 .10 .05 .584 6.251 7.815 .025 .01 9.348 11.345

Because 2 = 1.600 is between 0.584 and 6.251 in the Chi-Square Distribution Table, the area in the upper tail of the distribution is between 0.90 and 0.10. The p-value > . We cannot reject the null hypothesis. There is little evidence to support rejecting the assumption the population is normally distributed with = 71 and = 18.54.

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


CONTINGENCY TABLES
A frequency table in which a sample is classified according to the distinct classes of two different attributes is called a contingency table. It is often of interest to test the hypothesis that, in the population from which the sample was drawn, the two attributes are independent.

An mxn contingency table has m rows and n columns.

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


A typical mxn contingency table Rows (Attribute 2)
1 2 . i . m

Columns ( Attribute 1)
1 O11 O21 . Oi1. Om1 2 O12 O22 . Oi2. Om2 ... j O1j O2j Oij n O1n O2n . Oin. Omn Total R1 R2 . Ri . Rm

Omj

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


The expected frequency of the cell corresponding to i-th row and j-th column is found by

i th RowTotal j th ColumnTota l Ri C j E ij = = GrandTotal N


Using the observed frequencies given in the contingency table and the expected frequencies found using the above formula, we may test the null hypothesis that, H0: The two attributes are independent (or) the two attributes are not associated. H1: The two attributes are not independent (or) the two attributes are associated.

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES

The test statistic to test the above hypothesis is: m n (O E ) 2 ij ij 2 = Eij i j


2

( O E) for easy of understanding. 2 or simply = E


This statistic has chi-square distribution with (m-1)(n-1) degrees of freedom. The decision is to reject the null hypothesis H0 If the 2, is greater than the table value calculated value of of at level of significance corresponding to (m-1)(n-1) degrees of freedom.

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


EXAMPLE
The following data were collected in a study on the effectiveness of inoculation for a particular disease. The two attributes in this case are;

Attribute A: whether or not the person was inoculated; and Attribute B: whether or not they contracted the disease B

The 2x2 contingency table is Attribute A Inoculated Not Inoculated 10 30

Attribute B No disease 50 40

Disease

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


In this case the null hypothesis and alternative hypothesis are stated as,
H0: Contracting the disease is independent of inoculation H1: Contracting the disease is not independent of inoculation

Expected Frequencies
Expected frequencies Inoculated Not Inoculated Total Disease 18.5 21.5 40 No disease 41.5 48.5 90 Total 60 70 130

CHI-SQUARE TEST FOR INDEPENDENCE OF ATTRIBUTES


The test statistic is
2 =

( O E) 2
E
2

=
2

( O E)
E

. ( 1 0 1 85) = 1 85 .

. ( 5 0 4 15) + 4 15 .

. ( 3 0 2 15) + 2 15 .

. ( 4 0 4 85) + 4 85 .

= 1 05 .

The critical value for a 1% significance level with 1 d.f. is 6.63. The null hypothesis is therefore rejected at this level and it can be concluded that inoculation does have an effect on the probability of contracting the disease. From the contingency table it can be seen that inoculation reduces the risk.

Vous aimerez peut-être aussi