Hypothesis Testing Notes
Hypothesis Testing Notes
We carry out a hypothesis test by computing a test statistic and using it to make a
decision based on the data. Let’s consider this for our example.
Is our observed sample mean X =$96.1K so far from the claim of $98K that we can be
confident that the claim is wrong? Let’s compute how many standard deviations from
X−μ 96.1−98
= =−1.0364
expected our value is: σ 14.2
√n √ 60
The value we just calculated is called “test statistic”. The general formula for the test
statistic is
In our problem, the observed statistic is the observed sample mean of $96.1K, the
hypothesized parameter, in other words, the value of the parameter assuming the null
hypothesis is true, is $98K. What is the probability of the observed statistic value or the
value that is even less consistent with the null hypothesis? This probability is called p-
value. Formally, the p-value is a conditional probability defined as follows:
Is this strong enough evidence? Probably not. But we don’t know for sure.
Every hypothesis test carries a risk of making an error. There are two types:
Type I error: We reject the null when it’s actually true. We denote P(Type I error) by
α.
G. Steblovsky GR 521 Hypotheses Testing
Type II error: We do not reject the null when it’s actually false, and the alternative is
true. We denote P(Type II error) by β. The complement, 1 – β, is called the power of the
test.
Example.
1. A consumer group has accused a restaurant for using higher fat content than what is
reported on its menu. The group has been asked to conduct a hypothesis test to
substantiate its claims.
(d) Is the manager of the restaurant more concerned about Type I or Type II error?
(e) Is the consumer group more concerned about Type I or Type II error?
2. A quick and reliable screening process for detecting Covid was needed. Researchers
have developed an in-home antigen test. It gives a positive reaction in 98% of the people
who have that disease. However, it erroneously gives a positive reaction in 3% of the
people who do not have the disease. Answer the following questions using the null
hypothesis as “the individual does not have the disease.”
(a) What is a Type I error in the context of this problem? What is the probability of Type
I error?
Probability : 3%
(b) What is a Type II error in the context of this problem? What is the probability of
Type II error?
Probability : 2%
Let’s go back to our example. So, the p-value reports, “How likely is our observed data if
the null hypothesis is true?” Thus, small values of the p-value make us want to reject H0
… because if H0 was, in fact, true, the values we just observed are unlikely. A long-time
rule of thumb in practice has been to reject the null hypothesis when the p-value is less
than 0.05. More generally, we can choose a significance level α and reject the null when
the p-value is less than α.
One-Tailed Tests: For test where the alternative hypothesis is that the parameter is either
bigger or smaller than the stated value.
▪ Right-tailed Test: HA: the mean (proportion) is bigger than the stated value
H0: μ < μ0 versus HA: μ > μ0
▪ Left-tailed Test: HA : the mean (proportion) is smaller than the stated value
H0: μ > μ0 versus HA: μ < μ0
Two-Tailed Test: For test where the alternative hypothesis is that the parameter is
different than the stated value.
H0: μ = μ0 versus HA: μ ≠ μ0
Example:
1. Specify the appropriate null and alternative hypotheses for each situation and
determine if the hypothesis test is one-tailed or two tailed.
(a) Customers at Costco spend an average of $130 per trip (The Wall Street Journal,
October 6, 2010). One of Costco's rivals would like to determine whether its customers
spend more per trip.
X: money spent on a random trip
Ho: E(X)<=130
H1>130
(b) An article in the National Geographic News (February 24, 2005) reports that
Americans are increasingly skimping on their sleep. A researcher wants to determine if
Americans are sleeping less than the recommended 7 hours of sleep on weekdays.
X: the # of hours of sleep of a random American
Ho: E(X)>=7
HA:E(X)<7
(c) It is advertised that the average braking distance for a small car traveling at 65 miles
per hour equals 120 feet. A transportation researcher wants to determine if the statement
made in the advertisement is false.
X: branking distance of a random car
Ho=120
HA NOT EQUAL 120
Step 2. Specify the significance level α.
This is given, either as a percent or decimal
Standard values of α are 0.01, 0.05, 0.10
G. Steblovsky GR 521 Hypotheses Testing
Step 3. Assume the null hypothesis is true. Calculate the value of the test statistic and
the p-value or critical value.
The p-value is the probability of observing a sample statistic as extreme or more
extreme as the one derived from the given sample.
Decision rule: Reject H0 if p-value <α.
H0 HA P-value
= ≠ 2 P(Z ≥|z|)
Step 4. State the conclusion and interpret the results in the context of the problem.
We can make one of two decisions.
– Reject the null hypothesis
– Do not reject the null hypothesis
Reject the null hypothesis when the sample evidence is inconsistent with the null
hypothesis.
– Criminal court: guilty, enough evidence to convict
Do not reject the null hypothesis when the sample evidence is not inconsistent with
the null hypothesis.
– Not correct that “we accept the null hypothesis”. Sample information may not
be inconsistent with the null. But this does not prove the null hypothesis is
true
– Criminal court: “not guilty” rather than “innocent”
Draw a simple random sample of size n from a large population having unknown
mean µ. To test the null hypothesis that µ has a specified value,
H0: µ = µ0
compute the one-sample z-test statistic
x −μ
z=
σ /√ n
In terms of variable Z N ( 0 , 1 ), the P-value for a test of H0 against Ha:
Ha: µ > µ0 is P(Z ≥ z) = 1−NORM . S . DIST (z , 1)
Ha: µ < µ0 is P(Z ≤ z) = NORM . S . DIST (z , 1)
Ha: µ ≠ µ0 is P(Z ≥ |z|) = 2* NORM . S . DIST (z , 1)
G. Steblovsky GR 521 Hypotheses Testing
Draw a simple random sample of size n from a large population having unknown
mean µ. To test the null hypothesis that µ has a specified value,
H0: µ = µ0
compute the one-sample t-statistic
x−μ
t=
s/√n
In terms of variable T t n−1 ( 0 , 1 ), the P-value for a test of H0 against Ha:
Ha: µ > µ0 is P(T ≥ t) =T . DIST . RT (t , n−1)
Ha: µ < µ0 is P(T ≤ t) = T . DIST ( t ,n−1 ,1 )
Ha: µ ≠ µ0 is P(T ≥ |t|) = T . DIST .2 T (t , n−1)
Example:
1. Customers at Costco spend an average of $130 per trip (The Wall Street Journal,
October 6, 2010). One of Costco's rivals would like to determine whether its customers Alternate
spend more per trip. A survey of the receipts of 25 customers found that the sample mean
was $135.25. Assume that the population standard deviation is $10.50 and that spending
follows a normal distribution.
(a) Specify the appropriate null and alternative hypotheses to test whether average
spending at the rival's store is more than $130. z=135.25-130/10.5/sqrt(25)
P(z>2.5) = 1-P(Z<2.5) = 0.62%. It is inconsistent with Null hypothesis. We always interpret
the p-value with respect to the Null hypothesis, and we do not comment on alternative
hypothesis.
(b) Calculate the p-value. (What is the value of the test statistic?)
Z-Score
(c) What is the conclusion?
(d) If we set 0.1 as our Type I error rate, what would be your decision?