Sei sulla pagina 1di 58

1305AFE

Business Data Analysis

Statistical Inference

Statistical inference is the process by which we acquire


information about populations from samples. In this course
we will consider two applications of statistical inferences,
namely
Hypothesis testing:
Describing a single population

References: Chapter 12 (Sections 12.1-


12.4 & 12.6)

2
objectives
• Understand the fundamental concepts of hypothesis
testing
• Set up the null and alternative hypotheses, and be
familiar with the steps involved in hypothesis testing
• Test hypotheses regarding the population mean 
when the population variance is known
• Understand the p-value approach to testing
hypotheses and calculate the p-value of a test
• Test hypotheses regarding the population mean 
when the population variance is unknown
• Test hypotheses regarding the population proportion P
• Interpret the results of a test of hypothesis
Introduction

The purpose of hypothesis testing is to determine


whether there is enough statistical evidence in favour
of a certain belief about a population parameter.

Example
• In a criminal trial, a jury must decide whether the
defendant is innocent or guilty based on the
evidence presented at the court.
Concepts of hypothesis testing:
1. There are two hypotheses, the null and the alternative
hypotheses.
2. The procedure begins with the assumption that the
null hypothesis is true.
3. The goal is to determine whether there is enough
evidence to infer that the alternative hypothesis is
true.
In a criminal trial

A criminal trial is an example of hypothesis testing without


the statistics.
In a criminal trial, a jury must decide whether the
defendant is innocent or guilty based on the evidence
presented at the court.
In a trial a jury must decide between two hypotheses, the
null hypothesis H0 is
H0: The defendant is innocent.
The alternative hypothesis HA is
HA: The defendant is guilty.
In a criminal trial…
The jury does not know which hypothesis is true. They must
make a decision on the basis of evidence presented.
In the language of statistics convicting the defendant is
called
rejecting the null hypothesis (the defendant is
innocent) in favor of the alternative hypothesis (the
defendant is guilty).
That is, the jury is saying that there is enough evidence to
conclude that the defendant is guilty (i.e., there is enough
evidence to support the alternative hypothesis).
In a criminal trial…
If the jury acquits it is stating that

there is not enough evidence to support the


alternative hypothesis.

Notice that the jury is not saying that the defendant is


innocent, only that there is not enough evidence to
support the alternative hypothesis. That is why we never
say that ‘we accept the null hypothesis’ (that the
defendant is innocent).
Four possible outcomes from a hypothesis test
H0: The defendant is innocent
HA: The defendant is guilty.

Four possible outcomes Decision


1. Do not reject H0 when H0 is true Correct
2. Reject H0 when H0 is true Incorrect
3. Do not reject H0 when H0 is false Incorrect
4. Reject H0 when H0 is false Correct
Type I and Type II errors
Two possible errors can be made in any test.

A Type I error occurs when we reject a true null hypothesis


(i.e. reject H0 when H0 is true). In the criminal trial, a
Type I error occurs when the jury convicts an innocent
person.

A Type II error occurs when we don’t reject a false null


hypothesis (i.e. do not reject H0 when H0 is false). In a
criminal trial, a Type II error occurs when a guilty
defendant is acquitted.
Type I and Type II errors…
The probability of a Type I error is denoted as  (Greek
letter alpha). The probability of a Type II error is 
(Greek letter beta).
P (making Type I error) = 
P (making Type II error) = 

 is called the level of significance.


The two probabilities are inversely related. Decreasing
one increases the other.
In a criminal trial…
In our judicial system, Type I errors are regarded as more
serious. We try to avoid convicting innocent people (think
about capital punishment!). Therefore, we are more
willing to acquit a guilty person.

We arrange to make  small by requiring the prosecution


to prove its case and instructing the jury to find the
defendant guilty only if there is ‘evidence beyond a
reasonable doubt’.
A real world Application: How to test a claim

Is the product label acceptable?


Recently, a number of customer complaints were received
regarding the weight of the 500g garlic packs imported from
overseas by a particular wholesale distributor, Ausvege Ltd.
For example, garlic packs whose labels state that the contents
have a net weight of 500g must have a net weight of at least
500g.
However, it is impossible to check all garlic packs sold in the
country. As a result, statistical techniques are used.
A random sample of the product is selected and its contents
measured. If the mean of the sample provides sufficient
evidence to infer that the mean weight of all 500g Ausvege
garlic packs is less than 500g, the product label is deemed to
be unacceptable.
A real world Application: How to test a claim

Suppose that a government inspector weighs the contents of a


random sample of 25 garlic packs labelled ‘Net weight: 500
grams’ distributed by Ausvege Ltd
Using a 5% significance level, can the inspector conclude that
the product label is unacceptable? (Assume that the inspector
knows from previous experiments that the weight of all 500g
garlic packs distributed by Ausvege Ltd is normally distributed
with a standard deviation of 10g.) and n=25
Six-step process for testing hypothesis
Step 1: Set up the null and alternative hypotheses.
Note: Since the alternative hypothesis answers
the question, set this one up first. The null
hypothesis will automatically follow.

Step 2: Determine the test statistic and its sampling


distribution.

Step 3: Specify the significance level.


Note: We usually set  = 0.01, 0.05 or 0.10, but
other values are possible.
Six-step process for testing hypothesis…

Step 4: Define the decision rule.


Note: This involves using the appropriate
statistical table from Appendix B to determine
the critical value(s) and the rejection region.

Step 5: Calculate the value of the test statistic.


Note: Non-mathematicians need not fear. Only
simple arithmetic is needed.

Step 6: Make a decision and answer the question.


Note: Remember to answer the original
question. Making a decision about the null
hypothesis is not enough.
Step 1 :Set up the null and alternative hypotheses

Null and alternative hypotheses


Test on population means:
H0 : μ = μ0 (μ0 is a given value for μ)
HA: μ ≠ μ0 or HA: μ < μ0 or HA: μ > μ0

Test on population proportions:


H0: p = p0 (p0 is a given value for p)
HA: p ≠ p0 or HA: p < p0 or HA: p > p0
Step 1 :Set up the null and alternative hypotheses

One- and two-tail tests: A summary

One-Tail Test Two-Tail Test One-Tail Test


(left tail) (right tail)

Ho:  = o Ho:  = o Ho:  = o


HA:  < o HA:  ≠ o HA:  > o

o o o
Step 1 :Set up the null and alternative hypotheses

Hypothesis to test:
Right-tail test H0: μ=μ0
HA: μ>μ0
Level of significance = 

μ=μ0 xc 0 z
Rejection region: x > xc

If the selected sample gives a sample mean value very much larger than μ0,
then we should reject H0 for larger values of 𝑋.ത That is, the rejection region
in this case will be on the right tail of the sampling distribution of the test
statistic. Since P(reject H0 when H0 is true) = , the area of the whole right
tail will be equal to .
Step 1 :Set up the null and alternative hypotheses

Hypothesis to test:
Left-tail test H0: μ=μ0
HA: μ<μ0
Level of significance = 

xc μ=μ0
x -z 0
Rejection region: x < xc

If the selected sample gives a sample mean value very much smaller than μ0,
then we should reject H0 for smaller values of 𝑋.ത That is, the rejection region
in this case will be on the left tail of the sampling distribution of the test
statistic. Since P(reject H0 when H0 is true) = , the area of the whole left tail
will be equal to .
Step 1 :Set up the null and alternative hypotheses

Hypothesis to test:
Two-tail test H0: μ=μ0
HA: μμ0
Level of significance = 

H0: μ=μ0 H0: μ=μ0


HA: μ≠μ0 HA: μ≠μ0

-xc xc x -z/2 0 z/2

If the selected sample gives a sample mean value either very much larger or
very much smaller than μ0, then we should reject H0 for either larger or
ത That is, the rejection region in this case will be both tails
smaller values of 𝑋.
of the sampling distribution of the test statistic. Since P(reject H0 when H0 is
true) =  and the distribution is symmetric, the area of each tail will be equal
to /2.
Step 2: Test Statistic

Test statistics
We need to use a sample statistic to test a hypothesis.
Test on population mean, μ: Ho:  = o
a) If population variance σ2 is known
X  0
ത standardised test statistic:
Test statistic: 𝑋; Z ~N(0,1)
/ n

b) If population variance σ2 is unknown


X  0
ത standardised test statistic:
Test statistic: 𝑋; t ~tn-1
s/ n

Test on population proportion, p: Ho: p = po


p̂  p0
If np  5 and nq  5, Z
p0 q0 n
Test statistic: 𝑝;Ƹ standardised test statistic: ~N(0,1)
Step 4: Define the decision rule

A rejection region of a test consists of all values of the test


statistic for which H0 is rejected.
An acceptance region of a test consists of all values of the
test statistic for which H0 is not rejected.
The critical value is the value that separates the
acceptance and rejection region.
The decision rule defines the range of values of the test
statistic for which H0 is rejected in favour of HA.
Step 4: Define the decision rule

Under Standardised method – Z or t:

when sigma known


• (one tail- Right) : If Zcalc > Zcrit (alpha), reject Ho, otherwise do not reject Ho.
• (one tail- left) : If Zcacl < -Zcrit (alpha), reject Ho, otherwise do not reject Ho.
• (two tail) : If Zcalc < -Zcrit (alpha/2) or Zcal > Zcrit (alpha/2), reject Ho, otherwise do
not reject Ho.

when sigma unknown


• (one tail- Right) : If tcalc > tcrit (alpha, n-1), reject Ho, otherwise do not reject Ho.
• (one tail- left) : If tcalc < - tcrit (alpha, n-1), reject Ho, otherwise do not reject Ho.
• (two tail) : If tcalc < -tcrit (alpha/2, n-1) or tcal > tcrit (alpha/2, n-1) , reject Ho,
otherwise do not reject Ho.

Under p-value method


for all three types, one-tail left, one tail right, two tail

• Reject Ho if p-value < alpha, otherwise do not reject Ho.


A real world Application: How to test a claim

Example 1
Using a 5% significance level, can the inspector
conclude that the product label is unacceptable?
(Assume that the inspector knows from previous
experiments that the weight of all 500g garlic packs
distributed by Ausvege Ltd is normally distributed
with a standard deviation of 10g and n=25
A real world Application: How to test a claim

Testing the population mean when 2 is known


Data type: Numerical, single population (σ known)
Problem objective: To draw a conclusion about the mean
weights of 500g garlic packs.
We investigate whether the mean weight is less than 500
grams (that is, whether the product label is
unacceptable).

H0:  = 500
Then Left one-tail test
HA:  < 500

Based on the given data, sample mean 𝑋ത = 499.76.


A real world Application: How to test a claim

1. Our hypotheses
3. Level of significance:  = 0.05
H0:  = 500
HA:  < 500 4. Decision rule
Left one-tail test
Reject Ho if Zcalc < – zcrit = -1.645
2. The test statistic is: (or Reject Ho if p-value <  = 0.05)
X 
Z ~ N (0,1)
 n

5. Value of the test statistic under Ho:


X   499.76  500
Z   0.12
 n 10 25
A real world Application: How to test a claim

z-value method:
X   499.76  500
Z   0.12
  0.05  n 10 25
Do not
reject H0

x  499.76 500 x
A sample mean far below 500
Do not
should be a rare event if  = 500.   0.05 reject H0

Rejection region –0.12


–z = –1.645 0 z
6. Conclusion:
As Zcalc = -0.12 > -1.645 = zcrit, we do not reject Ho.
The p-value of a test of hypothesis…
The p-value of a test is the minimum level of significance that
is required to reject the null hypothesis.

p-value calculation
In general:
For a right tail test (HA: μ > μ0), p-value = P(z > z0)
For a left tail test (HA: μ < μ0), p-value = P(z < -z0)
For a two-sided test (HA: μ ≠ μ0), p-value = 2P(z >|z0|)

Decision rule
If p-value < , we reject H0.
If p-value > , we do not reject H0.
A real world Application: How to test a claim

p-value Method

p-value = P(Z < – 0.12) = 0.4522

  0.05

–0.12
Rejection region –z = –1.645 0

Conclusion: As p-value = P(Z < – 0.12) = 0.4522 > 0.05, we


do not reject Ho.
A real world Application: How to test a claim

INTERPRET
Since the value of the test statistic
does not fall in the rejection region,
Zcalc = -0.12 > -1.645 = zcrit
we do not reject the null hypothesis
in favour of the alternative hypothesis. There is insufficient
OR (alternatively) evidence to infer
that the mean is less
Since the p-value is greater than the than 500 grams.
level of significance,
P(Z < – 0.12) = 0.4522 > 0.05
we do not reject the null hypothesis in
favour of the alternative hypothesis.
Example 2: Time required to complete an
assembly line
The mean of the amount of time required to complete a
critical part of a production process on an assembly line
is believed to be 130 seconds. To test if this belief is
correct, a sample of 100 randomly selected assemblies
is drawn and the processing time recorded. The sample
mean is 126.8 seconds. If the process time is normally
distributed with a standard deviation of 15 seconds, can
we conclude that the belief regarding the mean is
incorrect?
Example 2: Solution IDENTIFY

Data type: Numerical, single population (σ known)


Problem objective: To test a hypothesis about population
mean μ. Is the mean different to 130?
1. Hypotheses: H :  = 130
0
HA:   130 Two-tailed test
2. Test statistic: 𝑋ത or standardised test statistic:
X  0
Z ~ N (0,1)
/ n
3. Level of significance: =0.05
Example 2: Solution… IDENTIFY
4. Decision rule
The rejection region is set up so we can reject the null
hypothesis when the test statistic is large or when it is
small.

Stat is ‘very small’ Stat is ‘very large’

That is, we set up a two-tail rejection region. The total


area in the rejection region must sum to , so we divide
this probability by 2.
Example 2: Solution… IDENTIFY

As  = 0.05, we have /2 = 0.025 and z0.025 = 1.96 and


our rejection region is Zcalc < –1.96 or Zcalc > 1.96.

=0.025 =0.025

-z.025 +z.025 z
0
= -1.96 = 1.96

Decision rule (z-value method):


Do not reject H0 if -1.96 ≤ z ≤ 1.96. Otherwise, reject H0.
Example 2: Solution… COMPUTE

5. Value of the test statistic

From the sample data, 𝑋ത = 126.8.


x   126.8  130
z   2.13
 n 15 100

6. Conclusion

Since Zcalc = –2.13 < Zcrit= –1.96, we reject Ho.


The p-value of a test of hypothesis

In Example 2, we obtained
Zcalc = -2.13
Since it was a two-tail test,
p-value = P(Z < -2.13) + P(Z >2.13)
= 2(0.0166) = 0.0332
The p-value of a test of hypothesis…

½ p-value ½ p-value
=0.0166 =0.0166

-2.13 2.13 z
0
The p-value of a test of hypothesis…

Therefore, if we select a level of significance larger


than 0.0332 (3.32%), the conclusion would be to
reject H0.

For example, if  = 0.05 (5%), p-value = 0.0332 <  =


0.05, so the conclusion is to reject H0 in favour of
HA: μ ≠ 130.
Testing the population mean when the
variance 2 is unknown

Recall that when σ is known, the test statistic


X 
Z
 n
is normally distributed
• if the sample is drawn from a normal population, or
• if the population is not normal but the sample is sufficiently
large.
When σ is unknown, we estimate σ by its point estimator
s, and the z test statistic is replaced by the t-statistic.
Inference with variance unknown

When  is unknown, we use its point estimator s and the


z-statistic is replaced by the t-statistic, where the
number of “degrees of freedom” , is n–1.
Testing the population mean when the
variance 2 is unknown…

If the population is normally distributed, the test


statistic for  when  is unknown is t.

X 
t
s n
This statistic is Student t-distributed with (n–1) degrees
of freedom.
Example 3 – Has production declined due to
new government regulations?

A manufacturer of television picture tubes has a production line


that used to produce an average of 100 tubes per day. because of
recently introduced government regulations, a new safety device
is installed, which the manufacturer believes will reduce the
average daily output. After installation of the safety device, a
random sample of 15 days’ production was recorded, as follows:
93 103 95 101 91 105 96 94 101 88 98 94 101 92 95
Assuming that the daily output is normally distributed, is there
sufficient evidence to allow the manufacturer to conclude that
average daily output has decreased following installation of the
safety device? (use  = 0.05.)
Example 3: Solution IDENTIFY

Identifying the technique


Data type: Numerical, single population
Problem objective: To describe the population of daily
output (X). We investigate whether the mean daily output is
less than 100 tubes (that is, whether output has decreased
following installation of the safety device).
Parameter of interest: Population mean μ
Population variance: 2 unknown, use s2 to estimate 2.
Distribution of X: Assume normal.
Example 3: Solution… IDENTIFY

1.Hypotheses: H0: μ = 100


HA: μ < 100 [Left one tail test]
X 
2. Test statistic: t  ~ tn 1 (since 2 unknown)
s/ n

3. Level of significance:  = 0.05


4. Critical value: -t,n-1 = -t0.05,14 = -1.761
Decision rule:
Reject H0 if tcalc < tcrit = -1.761; otherwise do not
reject H0.
CALCULATE
Example 3: Solution…

5. Value of the test statistic:


n=15,  X  1447 ,  X  139917 , 𝑋ത = 96.47, s2 = 23.55, s = 4.85
2

96.47  100
t  2.82
4.85 / 15

6. Conclusion:
t-value method
As tcalc = -2.82 < tcrit= -1.1761, reject H0.
There is enough evidence to conclude that mean daily
production has decreased after the installation of the
safety device.
CALCULATE
Example 3: Solution…
6. Conclusion (cont.):
p-value method
tcalc = -2.82
Need Excel to obtain p–value corresponding to t-statistic
From Excel: p-value (one tail) =TDIST(2.82,14,1)= 0.0068
Since p-value = 0.0068 <  = 0.05, we reject H0.

p-value = 0.0068
INTERPRET
Example 3: Solution…
Interpreting the results
There is enough evidence to conclude that mean daily
production has decreased after the installation of the
safety device.
Note that the results are valid only if the assumption that
daily output is normally distributed is true.
Testing the population proportion
When the population consists of nominal or categorical
data, the only test we can perform is about the
proportion of occurrence of a certain value.
Testing the population proportion…

Statistic and sampling distribution


The statistic employed is

x
p̂  where
n
x  the number of successes .
n  sample size .
Under certain conditions, [np  5 and nq  5],
𝑝Ƹ is approximately normally distributed, with
μ = p and σ2 = pq/n.
Testing the population proportion…
Ho: p = po
Test statistic for p

pˆ  p0
Z ~ N (0,1)
p0 q0 / n

where np  5 and nq  5.
Example 4: Is the market share large
enough to introduce a new product?

After careful analysis, a company contemplating the


introduction of a new product has determined that it
must capture a market share of 10% to break even.
Anything greater than 10% will result in a profit for the
company. In a survey, 400 potential customers are asked
whether or not they would purchase the product and
their responses were recorded. If 52 people respond
affirmatively, is this enough evidence to enable the
company to conclude that the product will produce a
profit? (Use  = 0.05.)
Example 4: Solution
Identifying the technique
Data type: Nominal (survey responses, yes/no), single
population
Problem objective: To describe the population of shoppers.
We investigate whether the new product will capture a
market share of more than 10%. We want to show that the new product
would be profitable
Parameter of interest: Population proportion p, proportion of
shoppers who would purchase the new product.
1. The hypotheses are:
H0: p = 0.10
HA: p > 0.10 Right-tail test.
Example 4: Solution…

2. Test statistic: 𝑝Ƹ
Standardised test statistic:
pˆ  p
Z ~ N (0,1)
pq n

3. Level of significance:  = 0.05


4. Decision rule:
Reject H0 if zcalc > zcrit =1.645
or Reject H0 if p-value < .
Example 5: Solution…

5. Value of the test statistic…


Sample proportion is 𝑝Ƹ = 52/400 = 0.13

The value of the test statistic is:


pˆ  p 0.13  0.10
z   2.00
pq / n (0.10  0.90) / 400

6. Conclusion:
z-value method:
Since z calc = 2.00 > z crit =1.645, we reject H0.
Example 5: Solution…
6. Conclusion (cont.):
p-value method:
p-value = P(z > 2.00) = 0.0228
Since p-value = 0.0228 < 0.05, we reject Ho.

There is sufficient evidence to reject the null hypothesis


in favour of the alternative hypothesis.

At the 5% significance level we can conclude that at


least 10% of shoppers will buy the product and the
product would produce a profit.
Homework questions

Please ensure you complete the allocated


homework activities prior to attending the
workshop session.

Information regarding the workshop content


can be found on the L@G website

Potrebbero piacerti anche