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

Lecture 39 - Hypothesis Testing

Uploaded by

ayeshaabid043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lecture 39 - Hypothesis Testing

Uploaded by

ayeshaabid043
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Inferential Statistics

&
Applied Probability

Course Code: DS221

Credits: 3

Instructor: Muhammad Sajid Ali

1
What is Hypothesis?
Definition:
A hypothesis is a statement or assumption about a
population parameter that we can test using sample data.

Example:
A company claims that the average salary of their employees is
500,0000 Rs per year.

We don't know the true average salary, so we want to test whether


the claim is reasonable based on our sample data.

2
What is Hypothesis?
 Statistics plays a key role in testing hypotheses and
verifying claims using data from random samples.

 Based on a random sample, we can use Statistics to


verify whether
– A system has not been infected

– The average connection speed is 54 Mbps, as claimed by


the internet service provide

– A hardware upgrade was efficient

3
Null and Alternative Hypothesis
 Null Hypothesis (H₀): the statement of no effect or no
difference. It is the hypothesis we assume is true unless
proven otherwise.

 Alternative Hypothesis (HA): the statement that


contradicts the null hypothesis. It reflects the outcome we
might observe if the null hypothesis is false.

Example
H₀: the average salary of employees is 500,0000.

HA: the average salary of employees is not 500,0000. 4


Null and Alternative Hypothesis
Example – 2: Let, we are interested in the “burning rate” of
solid propellant in aircrew escape systems which is a RV
described by a probability distribution.

Let we are specifically interested in mean rate i.e. in


deciding whether or not this values is 50 cm/s. This can be
formally expressed as:
– H0: μ = 50 centimeters per second
– HA: μ ≠ 50 centimeters per second

One-sided alternative hypothesis: Either μ<50 or μ>50


Two-sided alternative hypothesis: μ≠50

It is important to note that hypotheses are always


statements about the population or distribution and not5
about the sample
Type I and Type II errors
 When testing hypotheses, we realize that all we see is a
random sample.
 Therefore, with all the best statistics skills, our decision to
accept or to reject H0 may still be wrong i.e. may be due to
a sampling error.

 Four situations are possible

 In two of the four cases, the test makes the correct


decision by accepting a true hypothesis or rejecting a false
one. The other two cases are sampling errors. 6
Type I and Type II errors (Cont)
 Each error occurs with a certain probability that we hope
to keep small. A good test results in an wrong or
incorrect decision only if the observed data is somewhat
extreme.

 Type I errors more undesired, so we set a small α to


minimize them. We also try to reduce Type II errors (e.g.,
letting a guilty person go free), but Type I errors are
prioritized.

 Type I error probability called Significance level of a


test or α-error.

 The power of a statistical test is the probability of


rejecting the null hypothesis H0 when the alternative
hypothesis HA is true. 7
The P-value
 P-value tells us the likelihood of getting our data (or something
more extreme) if the null hypothesis is true.
– In other words, it measures how surprising our data is if there's actually no
effect or difference.

 A small p-value means that the observed result is surprising or


unusual assuming the null hypothesis is true. This suggests the
null hypothesis might be incorrect, and we might want to reject it.

 Small p-value = data is unlikely under the null hypothesis, so we


reject it.
 Large p-value = data is consistent with the null hypothesis, so
we fail to reject it.

8
The P-value
 By convention, p-values < 0.05 are often accepted as
“statistically significant” in the medical literature; but this
is an arbitrary cutoff.

 A cut-off of p<0.05 means that in about ONLY 5 of 100


experiments, a result would appear significant just by
chance (“Type I error”) so safe to use this value as
threshold to reject the Null hypothesis

 Null hypothesis is rejected when it is confirmed that


something unusual did not happen by chance but by
evidence collected in hypothesis testing

9
The P-value – Example
You are testing if a new drug reduces blood pressure.

Null Hypothesis (H₀): the drug has no effect (mean blood


pressure = baseline).

Significance level (α): You decide to use α = 0.05 (5%)


before testing

You collect your data, and the P-value from your test is
0.03

Since P-value = 0.03 < α = 0.05, you reject the null


hypothesis.

10
The P-value – Example
You are testing if a new drug reduces blood pressure.

Since P-value = 0.03 < α = 0.05, you reject the null


hypothesis.

P-value = 0.03 means that if the null hypothesis were true


(the drug has no effect),
– there is only a 3% chance of obtaining your observed data (or
more extreme results)

Since P-value (0.03) < α (0.05), you reject the null


hypothesis (H₀) and conclude that the drug likely reduces
blood pressure

11
Summary: Hypothesis Testing
 Define your hypothesis (null, alternative)

 Select the significance level (α), often 0.05 or 0.01.

 Do an experiment

 Choose the appropriate test (z-test, t-test, chi-sq, etc.)

 Calculate the test statistic

 Determine the p-value or compare the test statistic to the


critical value

 Make a Decision: Reject or fail to reject the null


hypothesis based on the p-value or critical value. 12
Hypothesis Testing – Example
A pharmaceutical company claims that its new drug lowers
the average blood pressure of patients by 10 mmHg.

You, as a medical researcher, decide to test this claim by


measuring the blood pressure of a sample of patients
before and after taking the drug.

You randomly select 12 patients and measure their blood


pressure before and after taking the drug.

13
Hypothesis Testing – Example
Step1 – Define the hypothesis:

Null Hypothesis (H₀): the drug decreases blood pressure


by exactly 10 mmHg
– H0​:μ=10

Alternative Hypothesis (HA): the drug does not decrease


blood pressure by exactly 10 mmHg.
– HA: μ ≠ 10

Step2 – Do the experiment:


Assume you randomly select 12 patients and measure
their blood pressure before and after taking the drug:

– Sample Differences=[9,11,10,12,8,9,11,10,10,10,9,10] 14
Hypothesis Testing – Example
Step2 – Do the experiment:
Assume yo randomly select 12 patients and measure
their blood pressure before and after taking the drug:

– Sample Differences=[9,11,10,12,8,9,11,10,10,10,9,10]

Calculate the sample mean (xˉ) and sample standard


deviation (s)
– Sample mean difference = 9.08
– Sample standard deviation (s) = 1.37

Step3 – Calculate the t-statistic:

15
Hypothesis Testing – Example
Step4 – Find the P-value:
We use a t-distribution table to find the P-value
associated with the t-statistic of -2.32 and n - 1 = 11
degrees of freedom.

For t = -2.32 and df = 11, the P-value is approximately


0.05 (this is a two-tailed test because the alternative
hypothesis is μ ≠10)

Step5 – Compare the P-value with α (significance level):

P-value = 0.05
α = 0.05 (commonly used significance level)
Since P-value (0.05) is equal to than α = 0.05, we can
accept or reject the null hypothesis.
16
Hypothesis Testing – Example

17
Hypothesis Testing – Example

This means we have sufficient evidence to conclude that


the drug may have an effect on blood pressure, and the
average decrease is may or may not be exactly 10 mmHg.

18
Hypothesis Testing – Example2
Ms. Smith's vote percentage is 55%

This is what we want to test, often called null hypothesis H₀

Should we reject this hypothesis, given the poll data?

19
Hypothesis Testing – Example2
 H₀: Ms. Smith's vote percentage is 55%

 The sample mean is 51% and stderr is 1.44%

 The test statistic x = (51 - 55) / 1.44 = -2.7778

 And the p-value for the test is: 0.0054

 P-value < 0.05, so we reject the hypothesis

20
Hypothesis Testing – Z table

21
Hypothesis Testing – Z table

22
P-value Caution
P-value use in scientific practice
Usually used to reject the null hypothesis that the data is
random noise
Common practice is p < 0.05 is considered significant
evidence for something interesting

Caution about p-value hacking


Rejecting the null hypothesis doesn't mean the alternative
is true
P < 0.05 is arbitrary and often is not enough for
controlling false positive phenomenon

23
Hypothesis Testing – Example3

Assume the mean weight of a male chow eating mouse is


35 gr. and the standard error of a sample of 44 such mice is
0.827 gr. What fraction of samples of 44 such mice will
have a sample mean in the range 33–37 grams?

24
Hypothesis Testing – Example3
The statistic to use is 𝑇 = ( (𝑠−35) / 0.827 )

The question is asking for the probability that t takes a value


in the range

To find the fraction of samples with means between 33 and


37 grams, we calculate the area between z = -2.42 and z =
2.42. The fraction (or probability) is the difference between
the probabilities.

= 0.9922 − 0.0078 = 0.9844 25


Hypothesis Testing – Example4

Assume the population mean of the weight of a chow-eating


female mouse is 27.8 gr and stderr of 0.70. Estimate the
fraction of samples that will have mean weight greater than
29 gr. Consider sample size of 48.

26

You might also like