04 Hypothesis Testing IITB PDF
04 Hypothesis Testing IITB PDF
2
Example
• Based on a study, it has been established that:
– On an average, blood platelet count lower than 75000
is indicative of a certain disease
• When a patient reports a blood count of 60000
– Should the doctor start treating the patient?
3
Example
• Based on a study, it has been established that:
– On an average, blood platelet count lower than 75000
is indicative of a certain disease
• When a patient reports a blood count of 60000
– Should the doctor start treating the patient?
• Questions:
– Is this value within expected variations?
– Or is it not?
– Are there any statistical tests that can help decide?
4
Statistical Hypothesis
• Statistical Hypothesis
– An assumption or a statement
– About one or two parameters
– Involving one or more populations
– May or may not be true
• Testing of Hypotheses
– Based on data samples
– Decide whether the hypothesis is true / false
• Example:
– Hypothesis: The patient is suffering from the disease
– Hypothesis: platelet count < 75000
5
The method of statistical hypotheses
• First of all we assume some hypothesis is correct
– (Not necessarily the one we believe to be true!)
– Example: The patient is not suffering from the disease
• Hypothesis: Platelet count is actually >= 75000
• This is known as the NULL hypothesis: H0
• We have to prove that the platelet count is – beyond doubt –
not a random variation of the real value.
• We then carry out a test
– The goal is to check if the result of the test is beyond
the limits of believability
– If it is, we have to reject our hypothesis.
6
Fundamental Concepts: Hypotheses Testing
• The Null and alternate • The Test Statistic
hypothesis – Numerical value of the test
statistic leads us to make the
– H0 = Null hypothesis decision
– H1 = Alternate • The Critical Region (CR) or the
hypothesis Rejection Region (RR)
– An interval determined by the
• Possible Decisions selection of appropriate
– Reject the Null distributions
hypothesis – Determines the region related to
the test statistic and used to
• This is the Goal: to prove decide the acceptance / rejection
with high probability of hypotheses
– Do not reject the Null • Conclusion and interpretation
hypothesis
7
The NULL hypothesis: H0
• We choose the NULL hypothesis H0 to be specific enough
and simple enough that we can actually compute the
likelihood of any given outcome of our observations
• NULL hypothesis is something that the data is likely to
reject
– Example:
• Assume : Average mean temperature is 98
• A sample measurement : 99
– Data indicates: Observed temperature is not normal
– Hypothesis H0 should be “Observed temperature is Normal”
8
The “alternate” hypothesis: H1
• The alternate hypothesis is something that we keep in
mind, and it is something that we would like to accept in
case the null hypothesis gets rejected.
• The alternate hypothesis is usually something that the
data will support.
• In our example:
– H1 : “Temperature is Not normal”
9
Stating the Hypothesis
Stating H0 and H1
1. Two tailed test
• H0 : P = P0 versus H1 : P P0
10
Outcome of Hypothesis Testing
• NULL hypothesis is rejected & Alternate
hypothesis is accepted
OR
11
Type I Error
• Consider the following situation:
– We reject the null hypothesis
– However, in reality, the null hypothesis is indeed true
– Therefore, we have rejected the null hypothesis, when,
in reality it is true
– This is called a TYPE I ERROR
• TYPE I errors False positives
• Probability of Type I error = α (the confidence level)
– Also known as “level of significance”
• Example: A healthy person is considered sick …
12
Type I Error
13
Type II Error
• Type II Error
– Failing to reject the NULL hypothesis even when in
reality it is false
• Probability of Type II Error: β
– It is very difficult to calculate this probability
– It depends on a variety of unknown parameters
14
Type I and Type II errors
• We would like to reduce both types of errors
• However, when we reduce probability of Type I
error we increase the probability of Type II error
– By making the test more stringent, we reduce the risk
of falsely rejecting the null hypothesis BUT increase
the risk of failing to reject it when we should
• That’s why the de facto value of 0.05 is so popular
• Note:
– Selecting a larger sample size minimizes both types of
errors
15
Size and Power of a test
• The size of a test is given by
α
• Power of a test is given by
(1 – β)
• Ideal we want our test to have:
– Low size AND
– High power
• The practice of computing the power of a test is
known as
– Power Analysis
16
Hypothesis Testing: Types
• About one parameter
– One proportion
– One mean
– One standard deviation
• About two parameters
– Two proportions
– Two means
– Two standard deviations
17
Steps in Hypotheses Testing
Classical Method
1. Determine and state H0 and H1
2. Decide the significance level and the critical
region
3. Based on the parameter, choose the test statistic
4. Using available data compute the test statistic
5. Make the statistical Accept or Reject decision
based on
a) Computed value of the test statistic
b) The critical region identified in step 2
18
Hypothesis Testing about one proportion
• Characteristics of the proportion
– Best estimate
– Standard deviation
– Conditions
• The sample is a simple random sample
• Sample values are independent of each other
• np(1-p) 10
19
Confidence levels and Critical Regions
• The most used values for are
– 0.01, 0.05, 0.1
– Distribution relevant to proportions
20
Example / Exercise
• Known from past surveys
– 35% of country’s citizens invest abroad
• Current Survey
– 800 adults were surveyed
– 320 were found to hold foreign assets
• Government wants to know
– If the foreign investment is still > 35%
– With 10% significance level
21
Solution (Classic Method)
• H0 : P <= 0.35 versus H1 : P > 0.35
– Right tailed test
• Significance level 10% = 0.1
• Z value associated with 0.1 = 1.28 (Normal Dist)
• Test to be done is as follows:
– Since it is right tailed test
– Hypothesis H0 can be accepted if calculated Z value is <= 1.28
(rejection region Z > 1.28)
• Calculated Z value
– = 2.965
22
The p-value
• The computed probability of getting the observed
result, or any result at least as extreme in its
difference from what the null hypothesis would
imply – is called the p-value
• A p-value of 0.05 is the de facto standard cut-off
between significant and non-significant results
• If this de facto value is used as the critical value, it
will result in wrong results 5% of the time
23
Steps in Hypotheses Testing: p-value method
p-value method
1. Determine and state H0 and H1
2. Decide the significance level
3. Based on the parameter, choose the test statistic
4. Using available data compute the test statistic and
the p-value
• How to calculate p-value?
5. Make the statistical Accept or Reject decision based
on
• and p-value
a) p-value less than should reject H0
b) p-value greater than should not reject H0
24
Solution: p-value method
• For two tailed tests
– P-value = 2 * P(Z < Zcal)
• For Left-tailed tests
– P-value = P(Z < Zcal)
• For Right-tailed tests
– P-value = P(Z > Zcal)
26
Hypothesis testing : Single Parameter
• The Mean, when variance is known
– Test statistic
• The Mean, when variance is unknown
– Large sample size (normal dist)
28
Solution: 1
• mu = 1.2 • Data indicates: reduction in time
• xbar = 1.05 • H0 : No change in mean time
• n = 100 • H1 : Change in mean time
• s = 0.5s
• Since we are testing equality, test is two tailed
• Since n > 30, normal distribution assumed
• At 0.01 significance levels, the z limits are
• 0.005 and 0.995
• z0.005 = -2.576 and z0.995 = 2.576
• Calculated z = (xbar – mu)/(s/sqrt(n)) = -3
• Since -3 is less than -2.576, it lies in REJECTION region.
• Therefore H0 is REJECTED and H1 is accepted
– Mean response time has changed from 1.2 seconds with the introduction
of the drug
• p-value method
– Calculated p-value: pnorm(-3) = -0.00135
– Since |-0.00135| < 0.01 (significance) p-value is less than significance.
Therefore, H0 is rejected & H1 accepted
29
Problem 2
• A major car manufacturer wants to test a new engine
to determine whether it meets new air-pollution
standards.
• The mean emission m of all engines must be less than
20 parts per million of carbon.
• Ten engines are manufactured for testing purposes
and the emission level of each is determined to be:
15.6 16.2 22.2 20.5 16.4 19.4 16.6 17.9 12.7 13.9.
• Does the data supply sufficient evidence to allow the
manufacturer to conclude this type of engine meet
the pollution standard?
– Test the hypothesis at a level a = 0.01.
30
Solution: 2
• n = 10 • Data indicates: emission < 20 ppm (xbar = 17.14)
• xbar = 17.14 • H0 : emission >= 20 ppm
• s = 2.9228 • H1 : emission < 20 ppm
• alpha = 0.01
31
Problem 3
• The National Science foundation, in a survey of
2237 engineering graduate students who earned
PhD degrees, found that 607 were US citizens; the
majority (1630) of the PhD degrees were awarded
to foreign nationals. Conduct a test to determine
whether the true percentage of PhD degrees
awarded to foreign nationals exceeds 50% at a
level a = 0.01.
32
Solution: 3
• n = 2237 • Data indicates: pcap > 0.5 (0.729)
• pcap = 1630/2237 = 0.729 • H0 : Proportion of degree to foreigners <= 0.5
• p0 = 0.5 • H1 : Proportion of degree to foreigners > 0.5
• alpha = 0.01