Module-4
HYPOTHESIS TESTING
Hypothesis Testing
• Hypothesis testing is a statistical method used to determine if there is enough evidence in a
sample data to draw conclusions about a population.
• It involves formulating two competing hypotheses, the null hypothesis (H0) and the
alternative hypothesis (Ha), and then collecting data to assess the evidence.
• A hypothesis is a statement or claim about a property of a population.
• Hypothesis testing is a procedure, based on sample evidence and probability, used to test
claims regarding a characteristic of a population.
• A hypothesis is a claim or statement about a characteristic of a population of interest to us. A
hypothesis test is a way for us to use our sample statistics to test a specific claim.
Hypothesis Testing
• Example 1
• The population mean weight is known to be 157 lb. We want to test the claim that the mean
weight has increased.
• Example 2
• Two years ago, the proportion of infected plants was 37%. We believe that a treatment has
helped, and we want to test the claim that there has been a reduction in the proportion of
infected plants.
• Example 3
• You say an average student in the class is 30 or a boy is taller than a girl. All of these is
an assumption that we are assuming, and we need some statistical way to prove these. We
need some mathematical conclusion whatever we are assuming is true.
Hypothesis Testing
Components of a Formal Hypothesis Test
Null hypothesis(H0): In statistics, the null hypothesis is a general given statement or default position that
there is no relationship between two measured cases or no relationship among groups
Alternative hypothesis(H1): The alternative hypothesis is the hypothesis used in hypothesis testing that
is contrary to the null hypothesis. Example: A company’s production is not equal to 50 units/per day etc.
Level of significance It refers to the degree of significance in which we accept or reject the null
hypothesis. 100% accuracy is not possible for accepting a hypothesis, so we, therefore, select a level of
significance that is usually 5%. This is normally denoted with \alpha
Hypothesis Testing
Why Hypothesis Testing is done
These samples mean values usually vary from the population mean by different ranges.
These ranges can deviate from very close to very far from the population mean. For making
correct inferences, our sample datasets need to resemble the properties of the population
dataset. So, these samples and the sample means are validated through various hypothesis
testing methods like the P-value method, Critical Value method, T-test, ANOVA test, etc.
Hypothesis Testing
P Value Method
• The P-value method is used in Hypothesis Testing to check the significance of the given Null
Hypothesis. Then, deciding to reject or support it is based upon the specified significance
level or threshold.
• A P-value is calculated in this method which is a test statistic. This statistic can give us
the probability of finding a value (Sample Mean) that is as far away as the population
mean.
• The P in P-value stands for Probability.
Hypothesis Testing
Now, we find the p-value associated with
the Z-score we calculated.
Then we refer the Z-table to find the
probability of the Z-score calculated.
Then, to find the p-value, we subtract that
probability from 1.
Hypothesis Testing
Null Hypothesis (H0) : The Average laptop units sold during the campaign were 500 (Average Laptop units
sold = 500)
Alternate Hypothesis (H1) : The Average laptop units sold during the campaign were not 500 (Average
Laptop units sold != 500)
Population Mean : 500
Population Standard Deviation : 45
Sample Mean (Sample_1) : 535.5
Sample Size (Sample_1) : 15
Alpha (Significance Level) : 0.05 (2-tailed Test)
Hypothesis Testing
Null Hypothesis (H0) : The Average laptop units sold during the campaign were 500 (Average
Laptop units sold = 500)
Alternate Hypothesis (H1) : The Average laptop units sold during the campaign were not 500
(Average Laptop units sold != 500)
The probability of Z-score comes out to be 0.99886
Thus, we Reject The Null Hypothesis.
Hypothesis Testing
Components of a Formal Hypothesis Test
Hypothesis Testing
Components of a Formal Hypothesis Test
Hypothesis Testing
Errors in Hypothesis Testing
A type I error is when the null hypothesis is rejected, but it is true.
• A type II error is not rejecting H0 when H0 is false
Hypothesis Testing
Example: A battery manufacturing company claims that the average life of its two-wheeler batteries is 2.1
years. The quality inspector surveyed ten customers to know the lasting period of their batteries. The
following data was collected:
Hypothesis Testing
We already know that the level of significance is 0.05, and the z-score is
1.645. Let us now compare the Z-test with it.
0.744 ˂ 1.645; therefore, the null hypothesis is true.
Thus, the company’s claim that the average life of its batteries is 2.1 years
is proven true.
Hypothesis Testing
Suppose a researcher claims that the mean average weight of men is greater than 100kgs with a standard
deviation of 15kgs. 30 men are chosen with an average weight of 112.5 Kgs. Using hypothesis testing,
check if there is enough evidence to support the researcher's claim. The confidence interval is given as
95%.
Hypothesis Testing
Conducting a hypothesis test
Hypothesis Testing
Hypothesis Testing Formula
Depending upon the type of data available and the size, different types of hypothesis testing are used to
determine whether the null hypothesis can be rejected or not.
Hypothesis Testing
Type I and II error
Depending upon the type of data available and the size, different types of hypothesis testing are used to
determine whether the null hypothesis can be rejected or not.
Hypothesis Testing
Level of significance
Hypothesis Testing
Critical Region
Test Statistics
Test Statistics
The statistical significance has to be assessed using p-
value. To assess statistical significance, it is important
to examine the test’s p-value.
Large sample Test
We take a sample of objects / units / participants / patients, etc. such as 70, 500, 1000, 10,000,
etc. This situation comes under the category of large samples. As a thumb rule, a sample of size
n is treated as a large sample only if it contains more than 30 units (or observations, n > 30).
Large-Sample Test of Hypothesis about a Population Mean
Example: Given a data set of 106 healthy body temperatures, where the mean was
98.2 and s = 0.62 , at the 0.05 significance level, test the claim that the mean body
temperature of all healthy adults is equal to 98.6
Large sample Test
Steps 1 and 2: Identify the hypotheses. Step 4: Select the significance level alpha. This is given in
our example to be 0.05.
Step 6: Reject H0 since the test statistic z falls in the critical
region in the left tail.
Hypothesis test for categorical variables
• Determine whether a sample of categorical variables is taken from a specific population (similar to the
t-test)
• Determine whether two variables affect each other and are associated to each other.
Chi Square Test
Hypothesis test
A scale is to be calibrated by weighing a 1000 g test weight 60 times. The 60 scale readings
have mean 1000.6 g and standard deviation 2 g. Find the P-value for testing H0
: μ = 1000 versus H1 : μ ≠ 1000.
Solution: Let μ denote the population mean reading. The null hypothesis says that the scale is in
calibration, so that the population mean μ is equal to the true weight of 1000 g, and the
difference between the sample mean reading and the true weight is due entirely to chance. The
alternate hypothesis says that the scale is out of calibration.
Since H0 specifies μ = 1000, regions in both tails
of the curve are in greater disagreement
with H0 than the observed value of 1000.6. The
P-value is the sum of the areas in both of these
tails, which is 0.0204
Therefore, if H0 is true, the probability of a result
as extreme as or more extreme than that observed is only 0.0204. The evidence against H0 is pretty strong.
It would be prudent to reject H0 and to recalibrate the scale.
Chi-square test of homogeneity
The chi-square test of homogeneity tests to see whether different columns (or rows) of data in a table
come from the same population or not (i.e., whether the differences are consistent with being explained by
sampling error alone).
A chi-square test for homogeneity is a test to see if different distributions are similar to each other.
chi-square test of homogeneity
Chi-square test of homogeneity
Find the chi-square statistic
0.078
Chi-square test of homogeneity
Find the degrees of freedom
3. Degrees of freedom (df) = (# of rows - 1)(# of columns - 1)
(2-1)(3-1) = 2
p-value=0.95
Calculated a p-value of 0.95, which is greater than the assumed significance level of 0.05. Therefore,
we fail to reject the null hypothesis, and the data does not support the claim that the distribution of
auto types purchased differs among all three states.
The Chi-square goodness of fit test is a statistical hypothesis test used to determine whether a
variable is likely to come from a specified distribution or not. It is often used to evaluate whether
sample data is representative of the full population.
The Chi-square test for homogeneity is used to check if the two variables follow the same
distribution.
The Chi-square test of independence checks whether two variables are likely to be related or not.
We have counts for two categorical or nominal variables. We also have an idea that the two
variables are not related.
ANOVA
• Analysis of variance, or ANOVA, is a statistical method that separates observed variance
data into different components to use for additional tests.
• A one-way ANOVA is used for three or more groups of data, to gain information about
the relationship between the dependent and independent variables.
• If no true variance exists between the groups, the ANOVA's F-ratio should equal close to
1.
ANOVA
The outcome of ANOVA is the ‘F statistic’.
This ratio shows the difference between the within group variance and the between group variance, which
ultimately produces a figure which allows a conclusion that the null hypothesis is supported or rejected.
If there is a significant difference between the groups, the null hypothesis is not supported, and the F-ratio
will be larger.
ANOVA
Analysis of variance, or ANOVA, is a strong statistical technique that is used to show the difference
between two or more means or components through significance tests.
It also shows us a way to make multiple comparisons of several populations means. The Anova test is
performed by comparing two types of variation, the variation between the sample means, as well as the
variation within each of the samples.
ANOVA
ANOVA
A One-Way ANOVA is used to determine how one factor impacts a response variable.
A Two-Way ANOVA is used to determine how two factors impact a response variable, and to
determine whether or not there is an interaction between the two factors on the response
variable
ANOVA
ANOVA
ANOVA Real Life Example #1
A large scale farm is interested in understanding which of three different fertilizers leads to the highest crop
yield. They sprinkle each fertilizer on ten different fields and measure the total yield at the end of the growing
season.
ANOVA Real Life Example #2
Medical researchers want to know if four different medications lead to different mean blood pressure
reductions in patients. They randomly assign 20 patients to use each medication for one month, then
measure the blood pressure both before and after the patient started using the medication to find the mean
blood pressure reduction for each medication.
ANOVA-Formulas
Example
Solution
Three different kinds of food are tested on three groups of rats for 5 weeks.
The objective is to check the difference in mean weight(in grams) of the rats
per week. Apply one-way ANOVA using a 0.05 significance level to the
following data:
If the calculated F-statistic is greater than the critical F-value, you would reject the
null hypothesis.
Please consult an F-table or use statistical software to find the critical F-value.
Now, we need to find the p-value associated with F(2, 15). Using statistical tables or
software, the p-value is extremely low (much less than 0.001). Since the p-value is
significantly less than the significance level of 0.05, we reject the null hypothesis. There
is enough evidence to conclude that there is a significant difference in mean weights
among the three types of food.
Thank You