Lec 31

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

LS: 31

MA2001D Mathematics III: Lecture 31


Module-2

Instructor: Vibhuti Arora

Department of Mathematics
National Institute of Technology Calicut

1 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
The Chi-squared test for Goodness of Fit

The Chi-squared test for Goodness of Fit

2 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
The Chi-squared test for Goodness of Fit

The test of goodness of fit is used to find out how the observed
value of a given phenomena is significantly different from the
expected value.
In Chi-square goodness of fit test, the term goodness of fit is
used to compare the observed sample distribution with the
expected probability distribution.
In other words, these tests show well the distribution you
selected fits to your data.

3 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
The Chi-squared test for Goodness of Fit

For example:
Consider the tossing of a die.
We hypothesize that the die is honest, which is equivalent to
testing the hypothesis that the distribution of outcomes is the
discrete uniform distribution
f (x) = 1/6, x = 1, 2, . . . , 6.

Suppose that the die is tossed 120 times and each outcome is
recorded.
Theoretically, if the die is balanced, we would expect each face
to occur 20 times.
The results are as follows:
Face : 1 2 3 4 5 6
Observed 20 22 17 18 19 24
Expected 20 20 20 20 20 20
4 2023-11-3, 13.17 Vibhuti Arora LS: 31
LS: 31
The Chi-squared test for Goodness of Fit

A goodness-of-fit test between observed and expected frequencies is


based on the quantity
n
X (oi − ei )2
χ2 = , (1)
ei
i=1

where χ2 is a value of a random variable whose sampling distribution


is approximated closely by the chi-squared distribution with n − 1 df.

The symbols oi is a set of observed (experimental) frequencies and ei


is the corresponding set of expected (theoretical or hypothetical)
frequencies.
Note that:

n
X n
X
oi = ei
i=1 i=1
5 2023-11-3, 13.17 Vibhuti Arora LS: 31
LS: 31
The Chi-squared test for Goodness of Fit

The goodness of fit test uses the chi-square distribution to determine


if a hypothesized probability distribution for population provides good
fit.
Hypothesis
Null Hypothesis: There is no significant difference between the
observed and expected value.

Decision rule:
Accept H0 if χ2 ≤ χ2α,n−1 and reject H0 if χ2 > χ2α,n−1 where χ2 is the
calculated value of chi-square obtained on using (1) and χ2α,n−1 is the
tabulated value at α level of significance.

6 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
The Chi-squared test for Goodness of Fit

Example:
The demand for a particular spare part in a factory was found to vary
from day-to-day. In a sample study the following information was
obtained:

Days : Mon Tue Wed Thu Fri Sat


No. of parts demanded : 1124 1125 1110 1120 1126 1115

Test the hypothesis that the number of parts demanded does not
depend on the day of the week. (Given: the value of chi-square
significance at 5, 6, 7, d.f. are respectively 11.07, 12.59, 14.07 at the
5% level of significance).

7 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
The Chi-squared test for Goodness of Fit

Sol.
Here we set up the null hypothesis, H0 that the number of parts demanded
does not depend on the day of week.
Under the null hypothesis, the expected frequencies of the spare part
demanded on each of the six days would be:

1124 + 1125 + 1110 + 1120 + 1120 + 1126 + 1115


= 1120(ei )
6

P6 (oi − ei )2
χ2 = i=1 = 0.179
ei
degree of freedom is 5.
χ20.05,5 = 11.07.
0.179 = χ2 ≤ χ20.05,5 = 11.07, the null hypothesis accepted at 5% level of
significance.
Hence the number of parts demanded are same over the 6 day period.

8 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

P-value

9 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

P-value

A p-value use to make the statistical decision of whether to


reject or fail to reject the null hypothesis.
P-value is the lowest significance level α that results in
rejecting the null hypothesis.

10 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

If p-value ≤ α then reject H0 .

If p-value > α then accept H0 .

11 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

Computing p-value

To compute a p-value all you do is find the area outside of the


test statistic value in normal curve-that is your p-value.

12 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

Example
Commonly prescribed drug for relieving nervous tension is believed to be 60%
effective. Experimental results with a new drug administered to a random
sample of 100 adults who were suffering from nervous tension show that 70
received relief. Is this a sufficient evidence to warrant that the new drug is
superior to the one commonly prescribed? Use a 0.05 level of significance.
Hint:

H0 : p = 0.6 v/s H1 : p > 0.6.


zα = z0.05 = 1.645.
Test statistic:
X − np0 70 − 60
Z0 = (under H0 , value of Z) = √ = p = 2.04.
np0 q0 (100)(0.6)(0.4)

Since Z0 = 2.04 > 1.645, reject H0 .


The P-value
P(Z0 > 2.04) = 1 − P(Z0 ≤ 2.04) = 1 − Φ(2.04) = 1 − .9793 = 0.0207 < α
13 2023-11-3, 13.17 Vibhuti Arora LS: 31
LS: 31
P-value

Example (for two sided)


Assume that
H0 : µ = µ0 = 8 and H1 : µ 6= 8
X = 9.5 and σ = 2
Then test statistic is
X − µ0
Z= √ = .559
σ/ n

P-value is
P{|Z| > .559} = 2P{Z > .559} = 2P{Z < −.559} = 2×.288 = .576
α = 0.05
The null hypothesis accepted as α = 0.05 < .576.

14 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

Testing of hypothesis for population mean when population variance


is known and under the null hypothesis H0 : µ = µ0 , Test Statistic
(TS)=
X − µ0

σ/ n

H1 : µ 6= µ0
p-value is 2P{Z ≥ |TS|}

H1 : µ > µ 0
p-value is P{Z ≥ TS}

H1 : µ < µ 0
p-value is P{Z ≤ TS}

15 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

16 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

Testing of hypothesis for population mean when population variance


is unknown and under the null hypothesis H0 : µ = µ0 ,
X − µ0
Test Statistic (TS)= √
S/ n

H1 : µ 6= µ0
p-value is 2P{Tn−1 ≥ |TS|}

H1 : µ > µ 0
p-value is P{Tn−1 ≥ TS}

H1 : µ < µ 0
p-value is P{Tn−1 ≤ TS}

where Tn−1 is a random variable with n − 1 degree of freedom:


P{Tn−1 > tα,n−1 } = α.
17 2023-11-3, 13.17 Vibhuti Arora LS: 31
LS: 31
P-value

Example (testing of Hypothesis for mean when population


variance is unknown)

H0 : µ = 180 v/s H1 : µ < 180.


α = 0.01
X = 169.5, S = 5.7 and n = 5
X − µ0
Test Statistic (TS) = √ = −4.12
S/ n
P − value = P{T4 ≤ −4.12} = P{T4 ≥ 4.12} ≈ 0.0075.
P − value = 0.0075 ≤ α = 0.01, the null hypothesis must be
rejected.

18 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31
P-value

Example

H0 : σ 2 = 225 and H1 : σ 2 > 225


n = 23 and Test statistic value is (n − 1)S2 /σ 2 = 19.36
Those numbers are 14.042 which has a right tail area of
0.90 and 30.813 which has a right tail area of 0.10
which imply that (0.10 < p < 0.90) > 0.05. Hence accept
H0 .

19 2023-11-3, 13.17 Vibhuti Arora LS: 31


LS: 31

– End –

20 2023-11-3, 13.17 Vibhuti Arora LS: 31

You might also like