STAT - Day 2-2
STAT - Day 2-2
Hypothesis Testing
Introduction to Statistics
Agenda
● Theory of Estimation
○ Point estimation
○ Sampling error
○ Interval estimation
● Hypothesis Testing
○ Terminologies
○ Decision making method
○ Test based on Z statistic
○ Error in hypothesis testing
Estimation
Inferential statistics
Inferential
Statistics
Theory of Testing of
Estimation Hypothesis
Point Interval
Estimation Estimation
Point Estimation
Estimate
Question:
What would be the average income of a 27-year-old in London? How would you
calculate it?
Estimate
Solution:
The trivial way is to collect the income data of every 27-year-old, further compute
its mean.
● If population parameters are not known they are estimated from the sample
A financial firm has created 50 portfolios. From them a sample of 13 portfolios was
selected, out of which 8 were found to be underperforming. Estimate the number of
underforming portfolios?
Point Estimate
Solution:
● It is the single value representation of the population that differs with each sample
● The deviation of the point estimate from the population parameter gives rise to
sampling error
Sample means of
different samples m2 m3 m1 m4
Sampling error
● Sampling error is the absolute difference between the population parameter and its
sample statistic (point estimate)
● Since the entire population is not considered as the sample, the values of mean,
median, quantiles, and so on calculated on sample differ from the actual population
values
The average temperature on a summer morning in Alaska is 55oF. The research student of
climate studies records the temperature for 15 summer mornings in oF.
Data = [49.8, 52.3, 51, 56.9, 54.8, 63, 58.2, 54.1, 50.4, 49.2, 47, 51.3, 43.5, 56, 55]
Point Interval
estimate estimate
Interval Estimation
● Interval estimate is a range or an interval within which the parameter lies for a stated
confidence level
● Confidence level (1-α) is the percentage of all possible point estimates that can be
expected to include the actual population parameter
● A 95% confidence level implies that 95% of the confidence intervals would include the
actual population parameter
Confidence level
Example:
The average income estimate for a 27-year-old in London is £45,000. After taking
repeated samples, the 99% confidence intervals of the average income include the
actual population parameter for 99% of the times.
Recall - CLT
For random samples of large size n taken from a single population with mean µ and
standard deviation σ, the sampling distribution of mean follows a normal distribution with
mean µ and standard deviation σ/√n
Interval estimate
100 bags of coal were tested and had an average of 35% of ash with a standard deviation
of 15%. Calculate the margin of error for a 90% confidence level.
Margin of error
Solution:
100 bags of coal were tested and had an average of 35% of ash with a standard deviation
of 15%.
Here n =100
σ = 0.15
A 90% CI with 2.46% margin of error implies that the sample mean will be within 2.46%
points of the real population value 90% of the time
Margin of error
Python solution:
● As sample size increases the margin of error decreases
For the previous question, for a margin of error 2.46. Verify whether you get sample size of
100.
Previous Question: 100 bags of coal were tested and had an average of 35% of ash with a
standard deviation of 15%. Calculate the margin of error for a 90% confidence level.
Interval estimate
Question:
● It can be said that from many samples drawn of size 250, construct a 95% CI for each
sample, roughly 95% of the intervals would actually contain the population parameter
µ
Confidence Interval
Question:
For the previous question, obtain the 90% and 99% confidence intervals. Further,
logically explain which one of them is the widest.
Interval estimate
A financial firm has created 50 portfolios. From them a sample of 13 portfolios was
selected, out of which 8 were found to be underperforming. Construct a 99% confidence
interval to estimate the population proportion.
Interval estimate
Solution:
● Sample mean, median, standard deviation are the examples of the point estimate
● Confidence interval returns the interval estimate for the population parameter
● Confidence interval is calculated using the point estimate and the margin of error
● The optimal sample size can be obtained by deciding the required margin of error
Inferential statistics
Inferential
Statistics
Theory of Testing of
Estimation Hypothesis
Non-Parametric Parametric
Tests Tests
Testing of Hypothesis
Question:
A manufacturer produces batteries. He claims that the life of his batteries is 25,500 hours.
Can we verify his claim?
Solution:
A trivial solution is to obtain the life of all the batteries produced by the manufacturer by
using them and thereafter verify this claim
However, by doing so all the manufactured products (batteries) will be exhausted and he
will not have any batteries to sell.
Examples:
Hypothesis
Null Alternative
Hypothesis Hypothesis
● Denoted by H a or H1
Hypothesis - example
A pharmaceutical has claimed to have produced a new drug which treats the patients
against cancer.
Hypothesis
Null Alternative
Hypothesis Hypothesis
● Now consider the effectiveness of the new drug is determined by the number of days
a patient requires to recover.
● The data for the number of days the patient take to recover are recorded
Hypothesis
It is claimed that the new drug
reduces the recovery time
H 0 : µ ≥ µ0 H 1 : µ < µ0
Here, µ0 is the general recovery
time
Hypothesis testing
● The alternative hypothesis has the burden of proof, i.e. from the data it will
have enough evidence to say the null hypothesis is false
Write the null and alternative hypothesis for the following scenarios:
H 0: µ = 60 Against H 1: µ ≠60
Two tailed test
Two-tailed test is a method in which the critical region of a distribution is split in its two tails.
It tests whether a sample is greater than or less than the population parameter.
A critical region is a region in which the null hypothesis is rejected. It is also known as
‘Rejection Region’.
Example
Solution:
A left-tailed test is a statistical hypothesis test set up to show that the sample parameter
would be lower than the population parameter.
Example
Solution:
A right-tailed test is a statistical hypothesis test set up to show that the sample parameter
would be higher than the population parameter.
Example
α
H 0: µ ≤13.5 Against H 1: µ > 13.5
Write the null and alternative hypothesis and identify the type of the test.
● To test the hypothesis that the mean diastolic blood pressure for a group of 85 adults
is less than 90mm
H0: μ ≤
To test whether the average number
Right Tailed Test
of boat rides are more than 10 per day 10 H1: μ
> 10
Errors in Hypothesis Testing
Probability of committing an error
● An α of 0.05 suggests that one is willing to accept a 5% chance that you reject a true
null hypothesis
● In order to lower this risk, set a lower α. However, it will be more difficult to reject the
false null hypothesis
Error in hypothesis testing
Test Decision
Reject H 0 Accept H0
● Denoted by β
● 1 - β is the power of the test, i.e. correctly rejecting a false null hypothesis
● In order to lower the risk of type II error, ensure the power of the test is high
● Test statistic, p-value and confidence interval are the three different criterias to test
the acceptance/ rejection of null hypothesis
● The p-value criteria returns the probability of getting the value greater than or equal to
the test statistic
● The null hypothesis is accepted if the confidence interval contains the specified
population parameter
Test statistic
● The decision whether to accept or reject the null hypothesis is based on the test
statistic value
● The test statistic is used to quantify the sample data that distinguishes the null and
alternative hypothesis
● The sampling distribution of a test statistic under the null hypothesis is used to
calculate the p-value
Procedure - using test statistic
P -value
● P-value is the probability associated with the test statistic
● P-value or ‘Calculated probability’ is the probability of finding the observed, or
more extreme, results when the null hypothesis (H0) of a study is true
● If the test statistic is available, the p-value is the probability of getting
observations equal to the test statistic as well as more extreme than the test
statistic given the distribution of observations
○ If p-value is less than 0.05 as obtained from the test statistic, it means that
there is less than 5 percent chance of getting the value of the test statistic
value as computed from the sample if the null hypothesis is true
○ In case of p-value is less than 0.05 (or less than the chosen significance
level), the null hypothesis is rejected and if it is more, then the null
hypothesis is accepted
The p-value
● The p-value is the mostly used criteria while performing the hypothesis test
● It is the probability of getting a value greater than or equal to the test statistic
● If T is the test statistic and T0 is calculated value then observed level of significance or
p-value is P(T>T0| H 0 is true)
● The test is significant if the p-value is less than or equal to the level of significance (α)
The p-value
● The smaller p-value supports the alternative hypothesis, as it exhibits the difference
between the observed data and the null hypothesis
Procedure - using p-value
Procedure - using confidence interval
Tests based on Z statistic
Tests based on Z statistic
Assumptions:
H0: The data is normal against H1: The data is not normal
● The hypothesis to test whether the population mean is equal to a specified value
H 0 : µ = µ0 against H 1 : µ ≠µ0
● It implies
● The hypothesis to test whether the population mean is equal to a specified value
● It implies
● The hypothesis to test whether the population mean is equal to a specified value
● It implies
Based on
H1 Based on critical region Based on p-value
confidence interval
A car manufacturing company claims that the mileage of their new car is 25 kmph with a
standard deviation of 2.5 kmph. A random sample of 45 cars was drawn and recorded their
mileage as per the standard procedure. From the sample, the mean mileage was seen to
be 24 kmph. Is this evidence to claim that the mean mileage is different from 25kmph?
(assume normality of data)
Test the claim using critical region technique, p-value technique and confidence interval
technique. [Use α = 0.01].
Two tailed test
Solution:
A car manufacturing company claims that the mileage of a car is 25 kmph with a standard
deviation of 2.5 kmph.
Thus µ = 25 kmph and σ = 2.5 kmph
A random sample of 45 cars was drawn and recorded their mileage as per the standard
procedure. From the sample, the mean mileage was seen to be 24 kmph.
Thus = 24 kmph and n = 45
To find: Evidence to claim that the mean mileage is different from 25kmph
Two tailed test
Solution:
To test, H 0 : µ = 25 against H 1 : µ ≠ 25
Decision: Reject H0, if |Zcalc| > Zα/2. Here |-2.68| > 2.575.
The CI = ( ) =( )
=
Since µ0 = 25, does not lie in the confidence interval, we reject H0.
Left tailed test
Question:
A sample of 900 PVC pipes is found to have an average thickness of 12.5 mm. Can we
assume that the sample is coming from a normal population with mean 13mm against that
it is less than 13 mm. The population standard deviation is 1 mm. Test the hypothesis using
the p-value method at 5% level of significance.
Left tailed test
Solution:
The p-value = P(Z < Zcalc, under H0) = P(Z < -15, µ = 13) = 0.00
An e-commerce company claims that the mean delivery time of food items on their website
in NYC is 60 minutes with a standard deviation of 30 minutes. A random sample of 45
customers ordered from the website, and the mean time for delivery was found to be 75
minutes. Is this enough evidence to claim that the mean time to get items delivered is more
than 60 minutes. (assume normality of data)
The p-value = P(Z > Zcalc, under H0) = P(Z > 3.35, µ = 60) = 0.0004
3.35
● The Z test can be used if the sample data is drawn from a normally distributed
population
● Two tailed as well as one tailed (left/ right) Z test can be performed
● The test statistic for the Z test follows normal distribution under the null hypothesis
● The test statistic, p-value and confidence interval can be used to analyze the
significance of the test
Thank You