You are on page 1of 22

TESTS AND ANALYSIS OF VARIANCE

STATISTICAL TESTS USING THE NORMAL DISTRIBUTION

Two-sided test of the expected value, µ

Ex. 1 Suppose that we visit a timber-merchant. Last year the average length of
timber has been 3000 mm with the standard deviation 400 mm. Now he has got a
new supplier and he wonders if the average length has changed. To examine this he
picks a stochastic selection of 16 boards and measures them carefully. The average
of these 16 boards is calculated to 3140 mm. Suppose that the length of a board is
normally distributed. Can we conclude that the average length of the boards has
changed using this examination?

Step 1: H0: µ = 3000


H1: µ ≠ 3000

α/2 = 0.025 α/2 = 0.025

Step 2: The significance level, α = 0.05


-1.96 1.96

x −µ
Step 3: The test statistic z = .
σ
n
Step 4: From the random sample we calculated x = 3140. ⇒

3140 − 3000
z= = 1.40
400
16

Step 5: H0 cannot be rejected. This examination does not support the statement
that there is a change of the average length.

The p-value is the largest significance level where we draw the conclusion that there
has been a chance,

z = 1.40 P(Z > 1.40) = 0.0808 p = 2 ⋅ 0.0808 = 0.1616

The confidence level 95% is chosen. A 95% is calculated

σ 400
x ± 1.96 ⇒ 3140 ± 1.96 ⋅ d.v.s. 3140 ± 196
n 16

The end points in the interval become 2944 – 3336. We see that the value 3000 is
covered by the interval. Therefore we cannot exclude that the true average still is
3000.
Upper tail test of the expected value, µ

Ex. 2 A coffee bar sells 320 cups of coffee every day at an average with the known
standard deviation 40 cups. After an advertisement campaign the cashier finds that
during the week (7 days) after the campaign she has sold 2450 cups of coffee. The
owner of the coffee bar wants to estimate if the campaign has had any effect on the
number of cups sold. Therefore he compares the number of cups sold before the
campaign with the number of cups sold after the campaign. Suppose the number of
cups of coffee sold per day is normally distributed.

Step 1: H0: µ ≤ 320


H1: µ > 320

α = 0.05
Step 2: The significance level, α = 0.05
1.645

x −µ
Step 3: Choose the test statistic z = .
σ
n
2450
Step 4: From the sample we obtain x = = 350 ⇒
7

350 − 320
z= = 1.98
40
7

Step 5: H0 can be rejected, i.e. the examination indicates that there has been an
increase.
Lower tail test of the expected value, µ

Ex. 3 In a company the manager is interested in the tenacity of a material. He used


a special method to measure which gives observation values that are normally
distributed with the known standard deviation σ = 2.5. If the measured value exceeds
40 units the material can be used. The risk that the company would discard material
even if the material fulfills the claim is determined to 0.1%. In a random sample the
average was calculated to 39.8 based on 16 measurements. Can the material be
accepted?

Step 1: H0: µ ≥ 40
H1: µ < 40
α = 0.001
Step 2: α = 0.001
zC

the critical value, zC, –3.1 is obtained from the table

x−µ
Step 3: The test statistic z =
σ
n

Step 4: The sample gives x = 39.8 using 16 observations

39.8 − 40
z= = -0.32
2.5
16

The z-value falls in the acceptance area.

Step 5: H0 cannot be rejected, i.e. this examination does not contradict the
statement that the material can be used.
The Power of the Test

Two types of mistake to be done type I error and type II error.

- The significance level is the probability to reject H0 when it is correct. Type I


error means that you incorrectly believe that a change has occurred.

- Type II error means that we don’t observe a change even if it has occurred.
The probability of type II error is denoted .

- If the significance level is big then H0 often will be rejected even though it is
true,

- If the significance level is small then it can be difficult to reject H0 even if there
has been a change and H1 is true.
-

- Unfortunately you can´t always believe in H0 even if H0 is true or reject H0 then


H1 is true. You have to decide which case what is most important.

The four possible decisions can be summarized in the following table:

H0 is correct H1 is correct
Accept H0 OK Type II error
Reject H0 type I error OK

P(Accept H0 | H0 is correct) = 1 – α

P(Reject H0 | H0 is correct) = P(type I error) = α(Significance level)

P(Accept H0 | H1 is correct) = P(type II error) = β

P(Reject H0 | H1 is correct) = 1 – β (The power)


α 1–α

µ0 µ1 µ0 µ1

β 1–β

µ0 µ1 µ0 µ1
Ex. 4 Suppose that ξ is N(µ, 20). Take a random sample of n = 100 and examine if
µ > 60. Suppose that the sample average is x = 63.40. Carry through the hypothesis
test and then calculate the power of the test for different values of  in the alternative
hypothesis.

Step 1: H0: µ ≤ 60
H1: µ > 60
α = 0.05

Step 2: Choose α = 0.05


1.645

x −µ
Step 3: The test statistic is z = .
σ
n

Step 4: From a random sample the average was calculated x = 63.40 ⇒

63.40 − 60
z= = 1.7
20
100

The z-value falls in the rejection area.

Step 5: H0 is rejected, i.e. this examination indicates that µ > 60.

What is P(type II error) = β and what is the power of the test, 1 – β?

x C − 60 20
z = 1.645 ⇒ = 1.645 ⇒ x C = 1.645 ⋅ + 60 = 63.29
20 100
100
P( ξ > 63.29 | µ = µ1) = 1 – β.

63.29 − 61
1) µ1 = 61 ⇒ P(Z ≤ ) = P( Z ≤ 1.145) = = 0.8739 ⇒ β = 0.8739 ⇒
20
100
The power = 1 – β = 0.1261.

63.29 − 65
2) µ1 = 65 ⇒ P(Z ≤ ) = P( Z ≤ –0.855) = 0.1963 i.e. β = 0.1963 ⇒
20
100
The power = 1 – β = 0.8037.

_____________________________________________________

The power for different values of µ1


_____________________________________________________
µ1 β Styrkan = 1 – β
61 0.8739 0.1261
62 0.7405 0.2595
63 0.5577 0.4423
64 0.3613 0.6387
65 0.1963 0.8037
66 0.0877 0.9123
67 0.0318 0.9682
68 0.0092 0.9908
69 0.0021 0.9979

The power function.

1,2

1,0

0,8
Styrkan

0,6

0,4

0,2

0,0
60 62 64 66 68 70
µ1
The relation between α, β and the sample size, n

Ex. 5 Suppose that ξ is N(µ, 30). Test H0: µ = 300 against H1: µ = 310.
Determine the sample size so that α = 0.05 and β = 0.036.

β = 3.6% α = 5%

µ0 = 300 µ1 = 310

σ 30
Condition 1: using µ0 and α: xC = µ0 + z0 ⋅ = 300 + 1.645 ⋅
n n

σ 30
Condition 2: using µ1 and β: x C = µ 1 + z1 ⋅ = 310 − 1.80 ⋅
n n

Let Condition 1 = Condition 2. i.e.

30 30 30
300 + 1.645 ⋅ = 310 − 1.80 ⋅ ⇒ (1.80 + 1.645) ⋅ = 310 – 300 ⇒
n n n

3.445 ⋅ 30
⇒ = n ⇒ n = 10.335 ⇒ n = 106.8 ≈ 107
10

The sample size 107 units is chosen.

σ 30
The critical value, x C = µ 0 + z 0 ⋅ = 300 + 1.645 ⋅ = 304.78
n 10.335
The t-test of the expected value µ

- The random variable is normally distributed.


- The population standard deviation, σ, is unknown and replaced by the sample
standard deviation, s.

Ex. 6 A new Chemical process is introduced in producing nickel-cadmium batteries.


The batteries produced by the old method have an average length of life of 102.5
hours. To be able to decide whether or not the new procedure will affect the average
length of life a random sample of 12 batteries produced by the new method was
taken. These batteries were tested until they stopped to work. The average length of
life of these 12 batteries was measured to be 107 hours with a standard deviation of
6.2 hours. Suppose that the length of life is normally distributed. Does the
examination suggest that there is an increase in the average length of life? Carry out
a test using a 5% significance level.

Step 1: H0: µ ≤ 102.5


H1: µ > 102.5 (n-1) = (12-1) df
α = 0.05

Step 2: α = 0.05.
tC

The degrees of freedom is n-1 = 12-1 = 11

The table gives that the critical t-value is 1.796.

x −µ
Step 3: The test statistic is t = .
s
n

Step 4: x = 107 and s = 6.2 ⇒

107 − 102.5
t= = 2.51
6 .2
12

Step 5: H0 is rejected. The examination suggests that µ > 102.5, i.e. the new
method seems to give an increase in the average length of life of the
batteries.
Test of a population proportion

Ex. 7 In a random sample of 200 persons who buy a special product there were 87
women. Can you from this investigation state that the product is bought to the same
extent by both male and female? Test the statement using 1% significance level and
calculate the p-value.

Step 1: H0: p = 0.5


H1: p ≠ 0.5
α/2 = 0.005 α/2 = 0.005

Step 2: α = 0.01
–2.575 2.575

p̂ − p
Step 3: The test statistic z = .
p(1 − p)
n
87
Step 4: p̂ female = = 0.435 ⇒
200

0.435 − 0.5
z= = –1.84.
0 .5 ⋅ 0 .5
200

Step 5: H0 cannot be rejected. The investigation does not suggest that the product
is bought more frequently by one of the sexes.

The p-value = 2P(Z < –1.84) =2 (1 – P(Z < 1.84)) = 2(1 – 0.9671) = 0.0658
Comparison between two expected values
Two samples

E(η) = E( ξ1 − ξ 2 ) = E( ξ1 ) – E( ξ2 ) = µ1 – µ2

σ12 σ 22
Var(η) = Var( ξ1 − ξ 2 ) = Var( ξ1 ) + Var( ξ2 ) = +
n1 n 2

Serveral different cases:

a) if the variables are normally distributed or not


b) if the variances are known or not
c) if σ12 = σ22 or not

The table shows the two different cases when we have large samples.

expected value distribution bound of error role of thumb

normal
σ12 σ 22 for all n1 and n2
µ1 – µ2 zα/2 +
n1 n2

σ1 and σ2 unknown
normal
s12 s 22
µ1 – µ2 zα/2 + estimated by
n1 n 2 s1 and s2
n1≥30
n2≥30

If σ1 = σ2 then we can estimate the common standard deviation using

2 (n1 − 1) s12 + (n 2 − 1) s 22
s =
n1 + n2 − 2
If the variables are not normally distributed then we must distinguish the following
situations.

expected distribution bound of error role of thumb


value

not normal
σ12 σ 22
µ1 – µ2 zα/2 + n1≥30
n1 n2 n2≥30

not normal
s12 s 22
µ1 – µ2 zα/2 + n1≥100
n1 n 2 n2≥100

Comparison between two proportions p1 and p2

η = p̂1 − p̂ 2 has the following expected value and variance:


E(η) = E( p̂1−p̂ 2 ) = E( p̂1 ) – E( p̂ 2 ) = p1 – p2

p1(1 − p1 ) p 2 (1 − p 2 )
Var(η) = Var( p̂1−p̂ 2 ) = Var( p̂1 ) + Var( p̂ 2 ) = +
n1 n2

If both n1 and n2 are bigger than 40,


n1 ⋅ p1 > 10
and
n2 ⋅ p2 > 10

Then we can use a normal approximation.


STATISTICAL TESTS USING THE χ2- OR THE F-DISTRIBUTION

One-sided test of the standard deviation, σ

Use the test statistic

(n − 1)S 2
η= 2
which is χ2{(n–1) df}.
σ

Ex. 1 A random sample of n=15 pills against


headache has the standard deviation s = 0.8% in
concentration of active substances. Suppose that the
concentration is normally distributed. Test if the value Against

of σ could possibly be less than 1.2. pain

Step 1: H0: σ ≥ 1.2


H1: σ < 1.2
0.95

Step 2: The significance level, α = 0.05


6.57

(n − 1)s 2
Step 3: The test statistic χ2 =
σ2

Step 4: From the random sample we calculated s = 0.8. ⇒

(15 − 1) 0.8 2
χ2 = = 6.22 < 6.57
1 .2 2

Step 5: H0 is rejected. It seems that the standard deviation is lower than 1.2.

If we want to compare two standard deviations, σ1 och σ2

s12 σ 22
Then we use the test statistic F = ⋅
σ12 s 22
which is F-distributed with (n1–1, n2–1) df.
ANALYSIS OF VARIANCE

+
x1 + + + + +
+ + x1 • + •
+
x2 + •
∗ ∗ • • ∗
x2 ∗ ∗ ∗ ∗ •
x3
∗ ∗ ∗

• •
x3 • •
• •

+ = observations from group 1


• = observations from group 2
∗ = observations from group 3

1. The samples from the different groups must be independent.

2. The observations are normally distributed with the same standard deviation
possibly with different expected values.

Why not test equality between two expected values at a time?

µ1 – µ2 = 0 µ2 – µ3 = 0 µ1 – µ3 = 0

These tests are not independent.

Suppose that we have 3 independent tests on 5% significance level each.

The probability of incorrectly rejecting one or more of these tests is

1 – 0.953 ≈ 0.14
MST
F = is F-distributed
MSE
där
MST means mean square of Treatments
MSE means mean square of Errors

One-way analysis of variance

ANOVA table

SS
sources of variation SS df MS =
df
Between treatments B−C c −1 (B − C) / (c − 1)
Error A−B n−c ( A − B) / (n − c)
Total A−C n−1

nj c nj
2
c nj c
( ∑ x ij ) ( ∑ ∑ x ij )2
i=1 j=1 i=1
A= ∑ ∑ x ij2 B =∑
nj
C=
n
j=1 i=1 j=1
Ex 1 A factory has 3 different line that produce the same type of electric bulbs. A
random sample of 3 lamps from each line is taken to examine if the averages of the
length of life are different depending on which line that has produced the bulbs. The
length of life was measured. This is the result:

Line no Length of life (hours)

1 1000 1100 1200


2 1000 900 1000
3 1300 1000 1100

Step 1: H0: µ1 = µ2 = µ3
H1: all not equal

Step 2: The degrees of the numerator 3 – 1 = 2.


The degrees of the denominator (9-1) – (3-1) = 6.

(2, 6) df

α = 0.05
5.14

MSlines
Step 3: The test statistic F =
MS error

Step 4: From the sample we obtain

c nj
A= ∑ ∑ xij2 = 10002 + 11002 + 12002 + 10002 + 9002 + 10002 +
j =1 i =1
+ 13002 + 10002 + 11002 = 10 360 000

nj

c
( ∑ x ij )2
i=1 1 1
B =∑ = (1000 + 1100 + 1200)2 + (1000 + 900 + 1000)2 +
j=1 nj 3 3
1
+ (1300 + 1000 + 1100)2 = 10 286 666.67
3

c nj
( ∑ ∑ x ij )2
j=1j=11
C = =
(1000 + 1100 + 1200 + 1000 + 900 + 1000 +
n 9
+ 1300 + 1000 + 1100)2 = 10 240 000
ANOVA table

SS
source of variation SS df MS =
df
between lines B − C = 46 666.67 2 23 333.335
error A − B = 73 333.33 6 12 222.22167
Total A − C = 120 000 8

23 333.335
F= ≈ 1.91
12 222.22167

Step 5: H0 cannot be rejected. This investigation does not give support to the
statement that the averages of the length of life differ between the lines.
Two way analysis of variance

One observation in each cell

SS
source of variation SS df MS =
df
between rows B −D c −1 (B − D) / (c − 1)
between columns C −D r −1 (C − D) / (r − 1)
error A −B−C+D (c − 1) (r − 1) ( A − B − C + D) / (c − 1)(r − 1)
Total A −D n −1

c r r c

r c r
( ∑ x ij )2 c
( ∑ x ij )2 (∑ ∑ x ij )
2

2 j =1 i =1 i = 1 j =1
A = ∑ ∑ x ij B =∑ C =∑ D=
i =1 j =1 i =1 k j =1 r n

Ex 2 A test using three different types of colour was accomplished for three different
types of cloth. One meter of each type of cloth was cut in tree equally sized pieces.
Each piece was randomly chosen to be handled by one of the tree types of colour.
The quality of a colour was measured as the wear of the fibre threads. The result is
shown in the following table. High values means a big wear and poorer quality.

Different types of colour


cloth A B C
1 36 40 35
2 43 48 44
3 22 26 22

a) Examine if the tree types of colour has the same quality.


b) Examine if the three types of cloth are equally much damaged by the colours.

Step 1: H0: µ1 = µ2 = µ3
H1: all not equal

Step 2: The degrees of freedom of the colours 3 – 1 = 2.


The degrees of freedom of the cloths 3 – 1 = 2 df.
The degrees of freedom of the denominator (9-1) – (3-1) – (3-1) = 4.

(2, 4) df

α = 0.05
6.94
MS colours
Step 3: The test statistic F=
MS error

Step 4: The sample gave us the following values

r c 2
A = ∑ ∑ xij = 362 + 432 + 222 + 402 + 482 + 262 +352 + 442 + 222 = 11 854
i =1 j =1

r
( ∑ x ij )2 1 1
j =1
B =∑ = (36 + 40 + 35)2 + (43 + 48 + 44)2 +
i =1 c 3 3
1
+ (22 + 26 + 22)2 = 11 815.333
3

c
( ∑ x ij )2 1 1
i =1
C =∑ = (36 + 43 + 22)2 + (40 + 48 + 26)2 +
j =1 r 3 3
1
+ (35 + 44 + 22)2 = 11 132.667
3

r c
( ∑ ∑ x ij )2 1
i =1 j =1
D = = (36 + 40 + 35 + 43 + 48 + 44 + 22 +
n 9
+ 26 + 22)2 = 11 095.111

ANOVA table

SS
source of variation SS df MS =
df
between cloths B − D = 720.222 2 360.111
between colours C − D = 37.556 2 18.778
error 1.111 4 0.27775
Total A − D = 758.889 8

18.778
F= ≈ 67.61 > 6.94
0.27775

Step 5: H0 is rejected. This examination supports the statement that there is a


difference in the quality of the colours.
b)
Step 4:
MS cloth
F=
MS error

360.111
F= ≈ 1296.53 > 6.94
0.27775

Step 5: H0 is rejected. This examination supports the statement that there is a


difference in how much the cloths are damaged by the colours.

Several observations in each cell - test of interaction

Ex 3 Three different types of nutritive substance were given to 24 rates, 12 male and
12 female. The result measured in increasing weight (in gram) is shown in the
following table.

Sustance
Sex A B C

Male 5 7 21
5 7 14
9 9 17
7 6 12

Female 7 10 16
6 8 14
9 7 14
8 6 10

ANOVA table

Source of variation SS df
Sex 0.67 1
Substance 301.00 2
Interaction 14.33 2
Error 94.50 18

Examine if there is any interaction between sex and substance.


Step 1: H0: No interaction between sex and substance
H1: There is an interaction between sex and substance.

Step 2: From the ANOVA table we obtain

The degrees of freedom of the numerator = 2.


The degrees of freedom of the denominator = 18.

(2, 18) df

α = 0.05
3.55

MSint eraction
Step 3: The test statistic F=
MS error

Step 4:
14.33
F= 2 ≈ 0.758 < 3.55
94.50
18

Step 5: H0 cannot be rejected. This investigation does not support the statement
that there is an interaction.

You might also like