Hypothesis Testing

Imagine a situation, where a Company’s mean weight of a product is 100 grams per container. Now how can you make sure that every container in the entire stock, that is the population, has the same weight of 100 grams per container?

To begin with, you can take a random set of 25 containers out of the whole stock, that is a sample and weigh them individually to take the sample mean, which is simply the average weight.

Extra: How to find the Mean…?

Source: The Student Line

Now there are different ways of determining whether the sample mean is equal to the population mean, here we use Hypothesis Testing

What is Hypothesis Testing?
It is a way of predicting the Population from the data collected through samples. This is called Inferencing or it is an inferential method.
As the name says, this is basically testing a hypothesis, a hypothetical situation.

Extra: Hypothesis Testing…?

Null & Alternative Hypothesis

Now we can expect the Population Mean to be 100 grams (of the entire stock) after looking at the Sample Mean (of the 25 containers) that is the Population Mean equal to the Sample Mean

Or it is not equal

Source: The Student Line

The first, claiming that they are equal is called the Null Hypothesis.
But this claim is just an inference to the Population from a random sample of 25 containers. So what if it is false or the Null is not true, that is why we need something called the Alternative Hypothesis.

Therefore, these two options are mutually exclusive, if Null is True, Alternative is False and vice versa.

In statistical terms we say,
if there is sufficient evidence that the weights of the sample 25 containers are above or below 100 grams, we reject the Null hypothesis, where the Alternative is accepted (The population mean is different from 100g)
In the real world, the Company would stop production and take the necessary steps to solve the problem.

If the Null is not rejected, meaning Population Mean is 100g and the Company can believe in its Processes and continue the normal way of production

But, can you be 100% sure that this is true? you cannot! because the Null is correct under a decision taken based on a sample of just 25 (25 containers).

Therefore, when we fail to reject Null (which means Null is true) we just say, “there is no sufficient evidence to reject the Null.”

In Summary,
01. A null Hypothesis is a belief that something is true
02. The alternative hypothesis is the opposite of Null, which is an inference we would like to prove (inferring the population mean through the sample mean)
03. Rejecting the Null means we have sufficient evidence to prove that the Alternative is correct
04. Do not reject Null means we fail to prove that Alternative is correct (but that does not necessarily mean we proved Null is correct)
05. Null Hypothesis refers to a Population parameter (μ), not a sample statistic (x̄)
06. Null Hypothesis always has an equal sign (μ equals 100g)
Alternative hypothesis never has an equal sign (μ not equal 100g)

So How this decision-making process of whether to reject the Null or not is decided?
In the critical value approach, we do this by computing the probability of getting the specified result, considering the Null hypothesis is true.
This probability is calculated by determining the Sampling distribution of the sample mean and the particular test statistic.

Extra: Sampling Distribution of Sample Mean…?

The sampling distribution of the sample mean follows statistical distributions like the standardized normal distribution, t distribution, etc.

Source: www.mathsisfun.com

The sampling distribution is divided into two parts namely the region of rejection and the region of non-rejection.

Source: programmathically.com

Now if the before-mentioned test statistic lies in the rejection region, we reject the Null, if it is in the non-rejection region we do not reject the Null. This is because the value of the test statistic is unlikely to occur when Null is true (when the mean is 100g)
Now how to determine where the rejection region is at and where it is not, for this you need to find the critical value, it is what divides the two regions.
The critical value depends on the size of the Rejection region And
the Rejection region depends on the risks of using samples to infer about populations. (remember? using the sample mean to predict the population means)

Source: onekobo.com

Risks? Risks of making an incorrect decision
- What if you reject Null even when its true and shouldn’t be rejected (Type I Error). and known to be a “false alarm”
- What if you do not reject Null even when it’s false and should be rejected (Type II Error). and known to be a “missed opportunity”

Extra: Type I and Type II Errors

Source: The Student Line

If we move back to our example, a Company’s mean weight of a product is 100 grams per container. And if we conclude that the Mean weight is not 100g even when it is 100g, it is a false alarm or Type I Error.
Similarly, if you conclude that the Mean weight is 100g even when it is not 100g, now that’s a missed opportunity to reconcile the error or Type II Error.

The probability of Type I occurring or we can say committing a Type I Error is α (alpha) the Level of significance. By specifying this value, you get to control the risk before conducting a Hypothesis Test. Normally specified at 0.01, 0.05, and 0.10.

α is the probability of rejection when Null is true. Does that make sense? Remember it is a false alarm where Null was wrongly rejected, so that’s why it is called so.
As mentioned before, now you can decide the size of the rejection region with the Critical Value since you know the Risk.

On the other hand Probability of Type II occurring or committing a Type II Erro is β (beta) the Beta Risk. In here, we cannot specify a value, because it depends on the Hypothesized values and the Actual Values of the Population parameter.

If the difference is large, β is small and if the difference is small, β is large.
For example, if the Mean weight is 102g where the difference is small as 2g, there is a large β or high risk that we will conclude that the Mean is still 100g. (Remember, this is about committing an error, that’s why when the difference is small, the risk of committing the error is large.

If for example Mean weight is 125g where the difference is 25g large, there is a small(beta) or low risk that we will conclude that the Mean is 100g.
(Similarly, here also it is about committing an error, since the difference is large, considering it we would not commit the error, therefore the risk is small.

End of the day, when it comes to the Hypothesis Tests, you will either make the correct decision or make any of the above two errors.

Source: The Student Line

Correct Decision? Yes
If you do not Reject Null when it should not be rejected, it is called the Confidence coefficient, the complement of Type I error (1 — alpha). (In our example, Concluding it is 100g when its actually 100g)
And
If you reject Null when it should be rejected, it is called Power of a statistical test, the complement of Type II error (1 — beta). (In our example, concluding that it is not 100g when it is actually not 100g)

Back to our example, the mean weight expected in all containers is 100g and we take 25 samples to check this. From the 25 randomly chosen containers we take the sample mean to compare with the population mean specified by the Company which is 100g.
So the Null is H0 : μ = 100, Alternative is Ha : μ ≠ 100
If the standard deviation can be calculated and if the Population is normally distributed (if not Central Limit Theorem can be used, that is, if n>30, can use the Z test) we use the Z test for the mean.

Extra: Central Limit Theorem…?

Source: The Student Line
https://www.instagram.com/p/Cd8YGwWp2vN/?hl=en

Z test statistic = (Sample Mean — Population Mean)/Standard error of the mean

Extra: Z test…?

Source: The Student Line
https://www.instagram.com/p/CfRWcQ4P_BX/?hl=en

01. Hypothesis Testing using the Critical Value Approach
The critical value approach compares this test statistic with the critical value (which is determined by the level of significance)
If the significance level is given as 0.05, the size of the rejection region equals 0.05.
And since the alternative hypothesis is Non-direction (≠), it is a two-tail test and has two rejection regions on either side. (0.05/2 -> 0.025 each side)
(if its Directional < or >, its one-tailed, and the rejection region is on a single side)

Source: sciencedirect.com

Therefore, in the normal distribution, the area below the lower critical value is 0.025, the area of the non-rejection region is 0.95, and the area above the upper critical value is 0.025.

Now we are required to look into the z-table to find the critical values according to the critical value.
You can either find 0.025 (area below the lower critical value) or 0.975 (area below the upper critical value) from the Z Table

Source: The Student Line
Source: The Student Line

It is -1.96 and 1.96 respectively.

Decision Rule, If Z stat is above 1.96 or below -1.96, Reject Null

Now if the Sample Mean of the 25 containers is 105 and the standard deviation is 15, the Z stat is (105–100)/(15/√25) = 1.67
Since 1.67 is in between 1.96 and -19.6, we do not Reject Null and say
“There is no sufficient evidence that the mean is different from 100g”

In summary,
1. State the Null and Alternative Hypothesis
2. Identify whether the Alternative Hypothesis is directional or non-directional
3. Identify the Rejection and Non-Rejection regions
4. Find the critical values from the Table
5. Perform the Test statistic
6. Look at whether the test statistic in rejection region or not
7. Decision of whether to reject or not

Source: The Student Line

P-value is the Probability of obtaining the observed result (100g in our example), that is the Null hypothesis is true(H0 : μ = 100)

If the p-value is less than or equal to α (alpha), Reject Null
If the p-value is greater than α (alpha), Do Not Reject Null

As mentioned above, a higher P-value means higher the probability of obtaining the observed result, which means Null is true, so Do Not Reject Null.

Remember we did not reject the Null in the Critical Value approach? because it was in the Non-rejection region.
Now we take the same example, a two-tail test, and we find the probability of getting the test statistic of 1.67.
To be exact the probability of Z stat value greater than 1.67 and the probability of a Z stat value less than -1.67.

From the Z table, Find the Probability as follows
If Directional, Ha : μ > 100, its P(Z>=1.67) => 1 — P(Z<1.67) = 1–0.9525 = 0.0475
If Directional, Ha : μ < 100, its P(Z<=-1.67) => 0.0475 (Rejection region is below -1.67, that’s why we took it as minus)

If Non-Directional, Ha : μ ≠ 100, its 2P(Z>=|1.67|) => 2[1 — P(Z<1.67)] = 2[1–0.9525] = 2[0.0475] = 0.095 (answer for this example)

If P-value < Alpha (Significance level) => Reject Null
Therefore, we Do not Reject Null since 0.095 is higher than alpha (0.05)

If the observed result/sample mean is 105g, which is 5g higher than hypothesized value(100g), the p-value is 0.095
“If Population Mean is 100g, there is 9.5% chance that you will get a sample mean different from 100g by at least 5g.”

In Summary,
1. State the Null and Alternative Hypothesis
2. Identify whether Alternative Hypothesis is directional or non-directional
3. Identify the Rejection and Non-Rejection regions
4. Find the critical values from the Table
5. Perform the Test statistic
6. Compute the p-value
7. Decision of whether to reject or not

Source: The Student Line

03. Hypothesis Testing with Confidence Interval Approach
If the hypothesized value is within the Interval, we do not reject Null (we are confident- that’s how I use to remember it)
If the hypothesized value is outside the interval, we reject the Null (we are not confident)
The confidence interval is calculated as follows,
Sample Mean +/- (Critical Value * Standard Error)

If Confidence Interval is 95%, alpha is 5%
alpha/2 -> 0.025 -> Z value from table is 1.96

In our example, n=25, x̄ = 105, SD = 15
x̄ — (Critical Value * Standard Error) <= μ <= x̄ + (Critical Value * Standard Error)
105 — (1.96*15/√25) <= μ <= 105 + (1.96*15√25)
105–5.88 <= μ <= 105+5.88
99.12 <= μ <= 110.88

Extra: Confidence Interval…?

Source: The Student Line
https://www.instagram.com/p/CeEGbk4v4gu/?hl=en

Therefore, since the hypothesized value of 100g is within the Confidence interval, we do not reject Null. There is no sufficient evidence to prove that the mean weight of the containers is not 100g.

In Summary,
1. Identify the Confidence Level and Alpha
2. Calculate the Critical Value
3. Calculate the Confidence Interval
4. Decision of whether to reject or not

Source: The Student Line

Now take a look at all 3 approaches, they gave out the same final decision.

References: Basic Business Statistics: Concepts and Applications (Twelfth Edition) : Mark L. Berenson, David M. Levine, David M. Levine

Comments