0% found this document useful (0 votes)
8 views

Hypothesis Testing Notes

Uploaded by

Hassan B. Izhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Hypothesis Testing Notes

Uploaded by

Hassan B. Izhar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

G.

Steblovsky GR 521 Hypotheses Testing

Introduction to Hypotheses Testing: The one-sample test for a mean


Example: A college claims that the average starting salary for recent graduates of their
online master’s program in data science is $98 thousand annually. A skeptical student
works hard to get a sample of 60 recent graduates. Their mean salary is $96.1 thousand,
with a standard deviation of $14.2 thousand dollars. Is this strong evidence that the
college is not being truthful?

A statistical hypothesis is a statement about a parameter of a distribution. In any


problem, there is a null hypothesis H0, which is a specific claim or statement, and an
alternative hypothesis Ha, which is usually which is the alternate conclusion. The
research goal is often to show that there is good evidence to reject the null hypothesis and
conclude (infer) that the alternative is correct.

For our example: H0: µ ≥ $98K, HA: µ < $98K

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

(observed statistic – hypothesized parameter)


standard deviationof the observed statistic

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:

p-value = P(the observed data or less consistent with H0 | H0 is true).

For our example the p-value is: NORM.S.DIST(−1.0364 , 1 ¿=0.15=15 %

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.

(a) What is the null hypothesis in words?

(b) What is a Type I error in the context of this problem?

(c) What is a Type II error in the context of this problem?

(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 α.

Let’s describe our approach in the 4-step procedure.


Step 1. Specify the null and the alternative hypotheses.
 One hypothesis is the null hypothesis.
– Denoted H 0
– Presumed default state of nature or status quo
G. Steblovsky GR 521 Hypotheses Testing

– Sharp hypothesis, always contains “equal” sign


 The other hypothesis is the alternative hypothesis.
– Denoted H A
– Contradicts default state of nature or status quo
– Always a statement about the range

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 <α.

Determining the p-value depends on the specification of the competing hypotheses.


We first explore the relationship between testing and confidence intervals. We can the
two sided test or “two tailed” hypothesis test for the mean by making the corresponding
confidence interval, and see if the hypothesized value is inside. If the significance level
for the test is α, the corresponding confidence level for the confidence interval for µ is
100*(1-α)%.

Let z be the value of the test statistic.

H0 HA P-value

= ≠ 2 P(Z ≥|z|)

H0 HA P-value Reject H0 if p-value < a


< > P(Z ≥ z)

> < P(Z ≤ z)


G. Steblovsky GR 521 Hypotheses Testing

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”

If using Excel, the procedure is:

 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

If population standard deviation σ is unknown and the sample estimate of σ is s, you


must use T-distribution instead of Z-distribution:

 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?)

(c) At the 5% significance level, what is the conclusion to the test?

2. (Two-Tailed Test) A local bottler in Hawaii wishes to ensure that an average of 16


ounces of passion fruit juice is used to fill each bottle. In order to analyze the accuracy of
the bottling process, he takes a random sample of 48 bottles. The mean weight of the
passion fruit juice in the sample is 15.80 ounces. Assume that the population standard
deviation is 0.8 ounce. Perform a hypothesis test at the 5% significance level:
G. Steblovsky GR 521 Hypotheses Testing

(a) State the null and


If Hothe
is alternative hypotheses
true, then X-bar for the test
48 ~N(16,0.8/sqrt(48)
X: mean weight of a random juice isz= 16-1.73 (left-tailed)
5% significance level means 2.5 at each tail.
alpha = 5% means 95% approx two standard deviations.
(b)InCalculate
two tailedthe p-value.
test, multiply the p value with 2, and if it greater than 5% then we
cannot reject the null hypothesis.

(WE DO NOT ACCEPT A NULL HYPOTHESIS, WE EITHER REJECT NULL


HYPOTHESIS OR NOT REJECT IT.)

Z-Score
(c) What is the conclusion?

(d) If we set 0.1 as our Type I error rate, what would be your decision?

You might also like